Repository navigation
Closed
Labels
bugSomething isn't working
Description
Summary
A prepared-summary swap keeps the messages after its mark verbatim, so the replacement can hold answer tool results (reply, noReply) from earlier Turns. The compaction handler still sets the Turn start to 0. For a gated Turn (Task or Thread agent Turn, Automation run), the earlier answer then counts as this Turn's answer. A resumed slice returns without calling the model, and the Turn ends with the earlier Turn's answer.
Code
packages/junior/src/chat/agent/index.ts at bafa715db:
applyActiveContextCompactioncallsrunResume.setTurnStartMessageIndex(0)after any replacement ("The whole replacement belongs to this Turn"). That holds for a blocking summary, which keeps only user messages. It does not hold forcompactWithPreparedSummary(services/context-compaction-swap.ts), which keeps every message after the mark.- The checkpoint then stores
turnStartSeq: -1, so the resumed record hasturnStartMessageIndex: 0. - On resume,
if (behavior.gated && readTurnAnswer(turnMessages())) return undefined;finds the earlier answer and skips the model. - Without a resume,
answer: readTurnAnswer(turnMessages())at Turn end and the missing-answer reminder (turnStartIndex()) read the same range.
Reproduction
Integration test through child-agent wiring:
- Named child. Turn 1 answers with
reply. - Commit long history and a ready
compaction_preparedat that seq. - Turn 2 answers with
noReply. - Lower
botConfig.contextWindowTokensso Turn 3 swaps at Turn start. - Turn 3 calls
systemTime, then yields (soft yield or Turn timeout).
Result: the paused record has turnStartSeq: -1, the resumed slice makes no model call, and the invocation completes with result "". Expected: the resumed slice calls the model and Turn 3 gets its own answer.
History
- feat(compaction): Swap in prepared background summaries #2605 (0.275.0) added the swap that keeps post-mark messages.
- fix(chat): Keep earlier Turn request context out of compaction #2301 added the Turn-start reset for replacements.
- feat(automations): Answer Automation runs with reply, noReply and reportBlocked #3145 (0.296.0) added the gated answer read and the resume early return.
Related
- Prevent silent completion after timeout resume #1030: silent completion after a timeout resume of a root Turn. Same symptom, different mechanism.
- Run every agent on one Conversation execution core #2567: the Turn boundary is an index into history that a replacement rewrites.
via @dcramer.
--
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
fix(agent): Commit fork history before the Turn starts
fix(agent): Carry positional seqs with agent history