Files
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

104 lines
4.3 KiB
YAML

# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/compaction/compaction-basic/README.md
/:
en: 4c3172f95eb524e1
zh: dd92ec1300ad9cbe
/deepseek-ai-dsh-compaction-basic:
en: 3ba5f9e37ab36328
zh: 2390a55415d4c27b
/deepseek-ai-dsh-compaction-basic/summary:
en: 31202d573182cc31
zh: e0a0c96f67a9c1ba
/deepseek-ai-dsh-compaction-basic/table-of-contents:
en: d152484eb41ac6b4
zh: bda879a892f240f0
/deepseek-ai-dsh-compaction-basic/use-this-package:
en: b40fa08b8ad55cca
zh: f8765a6f199c8c7b
/deepseek-ai-dsh-compaction-basic/use-this-package/what-you-get:
en: eb8e340061f72b98
zh: 327a51037b2d1adf
/deepseek-ai-dsh-compaction-basic/use-this-package/smallest-working-composition:
en: 24b0cc6db9c9f080
zh: 5adb5b585a45df95
/deepseek-ai-dsh-compaction-basic/use-this-package/tuning-when-condensation-starts:
en: 0a4bf89e1c55fed7
zh: 34463d8492922e92
/deepseek-ai-dsh-compaction-basic/use-this-package/what-happens-when-condensation-runs:
en: c872a8ef069596f0
zh: b3a48e309ae830d4
/deepseek-ai-dsh-compaction-basic/use-this-package/switching-models:
en: 0fc08b780180d8b0
zh: 5be0d1d75cd63c97
/deepseek-ai-dsh-compaction-basic/use-this-package/on-demand-condensation-with-compact:
en: 4c5067e4c57ca708
zh: 1c0e70319b9b2112
/deepseek-ai-dsh-compaction-basic/use-this-package/trimming-oversized-tool-outputs:
en: 1d6a74c0dc874dc8
zh: bcfa95549308c030
/deepseek-ai-dsh-compaction-basic/understand-the-implementation:
en: deb655b3b1860576
zh: 79f56e41a9dfe01f
/deepseek-ai-dsh-compaction-basic/understand-the-implementation/design-philosophy:
en: ed2d43610d4eaa83
zh: b46a1eaad396cdd7
/deepseek-ai-dsh-compaction-basic/understand-the-implementation/automatic-triggers-and-overflow-recovery:
en: 7691e9fb29065878
zh: ccfa41e63d1d2100
/deepseek-ai-dsh-compaction-basic/understand-the-implementation/summarization-mechanics:
en: 27dc309a746796b9
zh: 296de2eec3e992e5
/deepseek-ai-dsh-compaction-basic/understand-the-implementation/the-region-transaction:
en: 0aeb9cbe38489275
zh: 4791892033607bff
/deepseek-ai-dsh-compaction-basic/understand-the-implementation/config-resolution:
en: 313e019b1a9f8aa8
zh: 3c75d11b02adb693
/deepseek-ai-dsh-compaction-basic/understand-the-implementation/source-map:
en: 03784273b57e140b
zh: 8b699b5366452d9e
/deepseek-ai-dsh-compaction-basic/further-exploration:
en: 84b5b81eb9b5965d
zh: 7000af0fa502fcc1
/deepseek-ai-dsh-compaction-basic/model-experience:
en: 215e7ba838619b7b
zh: a311da3843709f90
/deepseek-ai-dsh-compaction-basic/model-experience/conversation-history:
en: 2e1148dd0f39a281
zh: cd68c9fff63534af
/deepseek-ai-dsh-compaction-basic/model-experience/conversation-history/what-the-model-sees:
en: d6b9cae50279a073
zh: 7ad313cc080c32fe
/deepseek-ai-dsh-compaction-basic/model-experience/conversation-history/what-the-model-sees/conversation-checkpoint-preamble:
en: 129d1eaba2519330
zh: 3ec517bdc6cb5ae3
/deepseek-ai-dsh-compaction-basic/model-experience/conversation-history/token-effect:
en: aa6987f4447e8499
zh: 7426d21e123bf74f
/deepseek-ai-dsh-compaction-basic/model-experience/conversation-history/kv-cache-effect:
en: deb2dbfea107d17e
zh: 018b694a1ae6f85e
/deepseek-ai-dsh-compaction-basic/model-experience/auxiliary-summarizer-request:
en: 7169bd02a7a6c396
zh: 7c62e3d4a97c73f7
/deepseek-ai-dsh-compaction-basic/model-experience/auxiliary-summarizer-request/what-the-model-sees:
en: 1f8ea990e7dff4b8
zh: 6d2a15f4e0ffb157
/deepseek-ai-dsh-compaction-basic/model-experience/auxiliary-summarizer-request/what-the-model-sees/compaction-instruction-final-user-message:
en: 39a362ee4890dbdb
zh: 3b98699120b1548e
/deepseek-ai-dsh-compaction-basic/model-experience/auxiliary-summarizer-request/token-effect:
en: 5e0679cb7cb4291a
zh: c9df8ebc526b05d9
/deepseek-ai-dsh-compaction-basic/model-experience/auxiliary-summarizer-request/kv-cache-effect:
en: d31d3e3d46542c91
zh: 5a42f873993e0c79
/deepseek-ai-dsh-compaction-basic/known-limitations-and-deferred-work:
en: b2d1bc66ca1056d3
zh: d9ef8014cd193a35
/deepseek-ai-dsh-compaction-basic/known-limitations-and-deferred-work/dev-note:
en: 1fec7b90c3b68c49
zh: ad9ae54a598846d0