---
title: "Record what a host-side compaction dropped (T846)"
method: POST
path: "/api/agent/sessions/{id}/compaction"
tags: ["Agent"]
---

# Record what a host-side compaction dropped (T846)

`POST /api/agent/sessions/{id}/compaction`

## Request

- Base URL: `http://localhost:38200`
- URL: `http://localhost:38200/api/agent/sessions/{id}/compaction`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `token`

Called by the ContextQ Claude Code plugin's session.compact hook. Writes exactly one checkpoint holding the dropped messages plus one `session.compact` trace event, and fires the context-pressure dream. Writes nothing when `DREAM_AUTO_TRIGGER_ENABLED=false` or when nothing was dropped.

## Path parameters

- `id` integer, required

## Request body

- object
  - `trigger` string, required
  - `agent_id` string, nullable: The subagent whose transcript compacted; null for the main loop.
  - `kept_count` integer, required
  - `dropped` object[], required
    - `role` string, required
    - `text` string, required

## Response `200`

Nothing written: `{written: false, reason}`.

## Other responses

- `201`: Written: `{written: true, checkpointId, checkpointSeq, traceSeq}`.
- `400`: Request body/query failed Zod validation.
- `401`: Missing or invalid credentials.
- `404`: Resource not found (or not visible to the caller).

---

[API](https://skmtc.dev/contextq/apis/contextq-api.md) · [All operations](https://skmtc.dev/contextq/apis/contextq-api/llms.txt) · [OpenAPI document](https://skmtc.dev/contextq/apis/contextq-api/revisions/7afc44056a22?raw)
