fix(chat): validate continuation events before delivering after compact - #1051
Merged
TheGreatAxios merged 2 commits intoSep 15, 2026
Conversation
Hosts answer each compaction continuation emit at most once via a seq-keyed consume-once gate, and the director holds unsolicited empty continuations with wait instead of inferring, so forged or replayed events cannot burn billable model turns.
…1060) Summary: update the architecture doc to the emit-and-deliver continuation mechanism; collapse idle-turn arming into a single-delivery contract (closure fires and the flag stays false, or no closure and the flag reports the arming) with a guard test; extract the session deliver generation re-check into runGenerationGuardedDeliver with race-pinning tests. Emit shape, guards, and gates unchanged. Verification: bun test src/tui/deliver-agent-message.test.ts src/agent/compaction.test.ts (38 pass); bun run check (7396 pass, 0 fail).
TheGreatAxios
merged commit Sep 15, 2026
30c886f
into
cl-7917-chat-director-replace-requestcontinuation-with-a-reactor
13 checks passed
TheGreatAxios
added a commit
that referenced
this pull request
Sep 15, 2026
) * feat(chat): express compaction continuation as a reactor emit action Removes requestContinuation from ChatDirectorOptions. The compaction governor now appends a custom.compaction.continue emit action wherever it previously invoked the closure, and the TUI and exec hosts answer that event by delivering the compaction continuation message. * fix(chat): validate continuation events before delivering after compact (#1051) * fix(chat): validate continuation events before delivering after compact Hosts answer each compaction continuation emit at most once via a seq-keyed consume-once gate, and the director holds unsolicited empty continuations with wait instead of inferring, so forged or replayed events cannot burn billable model turns. * fix(chat): pin continuation polish leftovers from emit-and-deliver (#1060) Summary: update the architecture doc to the emit-and-deliver continuation mechanism; collapse idle-turn arming into a single-delivery contract (closure fires and the flag stays false, or no closure and the flag reports the arming) with a guard test; extract the session deliver generation re-check into runGenerationGuardedDeliver with race-pinning tests. Emit shape, guards, and gates unchanged. Verification: bun test src/tui/deliver-agent-message.test.ts src/agent/compaction.test.ts (38 pass); bun run check (7396 pass, 0 fail).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stream sinks answered any custom.compaction.continue event with an unconditional deliver, so a forged or duplicated continuation cost one billable model turn per event on a fresh director (and reset loop-protection budgets). Hosts now answer each continuation emission at most once via a seq-keyed consume-once gate, and the director answers an unsolicited empty continuation with wait instead of infer.
Verification
Fixes CL-7976