Summary
When compaction happens mid-task, the agent may stop or get confused because the conversation context was just replaced with a summary. The runtime should automatically inject a "Continue with the task" message and keep the loop going.
What OpenCode does
After compaction, if auto: true, OpenCode inserts a "Continue" user message to keep the agent working. If overflow occurred mid-stream (no finish), it replays the last real user message after compaction.
Proposed implementation
In maybeManageContext() (native_compaction.go), after successful compaction:
- Append a synthetic user message like
"Continue with the task based on the context above."
- Ensure the loop continues iterating rather than returning
- If compaction happened during tool execution, include context about what was being done
Priority
P0 — without this, compaction during long tasks silently breaks the agent's flow
🤖 Generated with Claude Code
Summary
When compaction happens mid-task, the agent may stop or get confused because the conversation context was just replaced with a summary. The runtime should automatically inject a "Continue with the task" message and keep the loop going.
What OpenCode does
After compaction, if
auto: true, OpenCode inserts a "Continue" user message to keep the agent working. If overflow occurred mid-stream (no finish), it replays the last real user message after compaction.Proposed implementation
In
maybeManageContext()(native_compaction.go), after successful compaction:"Continue with the task based on the context above."Priority
P0 — without this, compaction during long tasks silently breaks the agent's flow
🤖 Generated with Claude Code