Files
deepseek-harness/packages/compaction
Kexin Liu da3ba0f245 feat(agent-loop): recover inbox claims before step start (#9145)
* feat(agent-loop): recover inbox claims before step start

* fix(acp): withdraw pending prompts at settlement

* fix(goal): withdraw stale rounds when restoring agents

* refactor(agent-loop): fold inbox claims with the queue

* fix(agent-loop): preserve the inbox wire conversion

* refactor(agent-loop): clarify inbox projection updates

* refactor(agent-loop): keep inbox recovery internal

* refactor(agent-loop): simplify inbox recovery

* refactor(agent-loop): clarify inbox claim recovery

* refactor(agent-loop): clarify when input returns to inbox

* refactor(agent-loop): let the inbox own claim return

The inbox projection groups queues and claims symmetrically and
ReactLoopInbox decides whether a failed turn returns its claim from its
own clear() and claim() calls; the loop's running phase keeps no return
flag. Resume restores the interrupted claim through an unconditional
inbox call after announce. The projection tests become a transition
table and the two Agent Notes merge into one.

* fix(agent-loop): drop inherited claims at a fork's seed cut

A cold read of a crashed parent closes its open turn as interrupted
inside the inherited prefix, so the child projected the parent's claim
and restored it into its own queue. The inbox fold now empties both
claim lists at an inherited session/end-seed; a fork keeps the parent's
queue but never the input the parent had taken out of it.

* test(agent-loop): resume a stored fork of a crashed parent without reviving its claim

* fix(compaction-basic): check model-switch pressure at pre-step so a failed switch returns the input

The switch check ran in agent/request, after step/start had settled the
claimed batch, so a Stop, a failed summary, or an exit during that
summary lost the prompt. The step's route is already fixed at
agent/pre-step, where the inbox still owns the claim; the check now
prices the selected route there and the agent/request listener is gone.

* docs: regenerate the event graph after compaction-basic left agent/request

* fix(agent): keep the model-switch notice ahead of context snapshots

With the switch compaction at pre-step, the runtime-context snapshot is
already part of the admitted batch when the notice is added, so an
appended notice landed after it. The notice now precedes the first
context snapshot, keeping the order the model saw before; the
model-switch-compaction snapshot is refreshed for the compaction events
now preceding step/start.
2026-11-26 18:10:58 +08:00
..
2026-11-22 15:27:28 +08:00

description, kind
description kind
Package map for the conversation-condensing feature family: automatic compaction, the on-demand /compact command, and tool-output trimming. package-group

compaction/ — compaction capability family

English | 中文

Summary

The compaction/ group keeps long agent conversations working near the model's context limit: older history is condensed into a summary automatically as token pressure builds, on demand with /compact, oversized tool outputs can be trimmed first so there is less to condense, and images an image-capable route can no longer send are replaced with placeholders. The shipped dsh base enables the feature by default — mount the packages explicitly to tune when and how condensation happens. The token measurement that decides when to condense lives in a separate LLM-family service.

Table of Contents


Packages

Each package below provides one piece of the feature; open a package page for how to use it.

Package Role ctx key
compaction/ The shared condensation contract: the operations and summary format every backend and trigger use ctx.compaction
compaction-basic/ Automatic condensation of older history into a summary as token pressure builds registers ctx.compaction
compaction-tool-result-pruner/ Trims oversized tool outputs so less history needs condensing ctx.toolResultPruner
compaction-image-offload/ Replaces over-budget request images with placeholders when an image-capable route rejects a request listens to agent/request-error
command-compact/ The /compact command to condense history on demand registers on ctx.commands

Start with the subsystem reference for the shared vocabulary, then read the two Agent Notes for the design rationale.

Dev Note

Working context for maintainers — click to expand

None.