fix: improve compaction continuation to prevent agent from stopping#16073
fix: improve compaction continuation to prevent agent from stopping#16073guazi04 wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
f2393f9 to
8554493
Compare
dee4fe2 to
1c1afaa
Compare
After compaction, the synthetic continuation message gave the model
permission to stop ('or stop and ask for clarification'), causing the
agent to frequently stop working instead of resuming the task.
Changes:
- Replace ambiguous continuation message with assertive directive
that instructs the model to continue from where it left off
- Enhance compaction summary prompt with sections for current status,
remaining tasks, next actions, and open questions
- Inject session todo list into compaction prompt so the summary
agent faithfully captures remaining work
- Include incomplete todos in continuation message to give the model
explicit next steps after compaction
Closes anomalyco#13217
1c1afaa to
d58306a
Compare
d58306a to
7e45d36
Compare
|
I make a fork that essentially rebases this commit onto the current dev branch (current as of when I made it, it's probably already behind) to try this. It's certainly a significant improvement. I'm using qwen3.5:9b on a locally hosted Ollama instance. |
Issue for this PR
Closes #13217
Type of change
What does this PR do?
After compaction, the agent frequently stops working instead of continuing. This affects all providers and has been confirmed by 8+ users.
Root cause: Two issues combine:
The synthetic continuation message after compaction says "Continue if you have next steps, or stop and ask for clarification" — this gives the model explicit permission to stop. After seeing a compressed summary, models frequently choose to stop.
The compaction summary prompt doesn't ask for remaining tasks or next actions. Without clear direction in the summary, the model has nothing to continue with.
Fix (single file,
compaction.ts, +47/-2 lines):Replaced the continuation message with an assertive 3-line directive that tells the model to read the summary and take the next concrete step. It still allows asking questions when genuinely blocked on missing info.
Enhanced the summary prompt with 4 new sections: current status, remaining tasks, next actions, and open questions — so the summary captures what to do next.
Inject session todos into the compaction prompt unconditionally (even when a plugin provides a custom prompt), so the summary agent faithfully captures remaining work.
Include incomplete todos in the continuation message with an explicit instruction to resume the in-progress item.
I identified this by studying how oh-my-opencode's plugins (compaction-context-injector, todo-continuation-enforcer) solve this same problem — they enrich the compaction context and aggressively prevent the model from stopping. This PR brings the core fix upstream without requiring plugins.
How did you verify your code works?
bun typecheckpasses cleanlyexperimental.session.compacting) continues to work as beforeScreenshots / recordings
N/A — backend logic change, no UI impact.
Checklist