Bug Description
I often run multi-round work in a single subagent session (the task tool with task_id, experimental.allowSubAgents: true — a subagent on a long task needs DCP to prune its own context). Nothing looks wrong unless the model goes back and reads them. In a real session this made the main agent conclude the subagent was repeating itself, and it re-sent the same instruction byte-for-byte over and over.
Minimal reproduction
- Enable
experimental.allowSubAgents: true.
- Dispatch a subagent with a small question, asking it to start its reply with
ROUND-1-MARKER.
- Resume it twice via
task_id with two different questions, asking for ROUND-2-MARKER / ROUND-3-MARKER.
- After round 3, compare the three task results in the main agent's context with what's stored.
What I get:
| layer |
round 1 |
round 2 |
round 3 |
| subagent's actual replies |
ROUND-1 + answer A |
ROUND-2 + answer B |
ROUND-3 + answer C |
| task results in parent DB |
A ✓ |
B ✓ |
C ✓ |
| task results in the model's input |
C ✗ |
C ✗ |
C ✓ |
Root cause in brief: injectExtendedSubAgentResults replaces the whole <task_result> body with the subagent session's current last assistant text. The cache that's supposed to pin each call's correct text (subAgentResultCache) lives in DCP's singleton session state, which is reset on every session switch — and a resumed subagent runs its own model calls through the same hook between the parent's turns, so the cache is empty on every single parent call. No server restart or special environment needed; any resumed session hits this every round.
{
"$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json",
"compress": {
"maxContextLimit": "60%",
"minContextLimit": "35%",
"nudgeFrequency": 3
},
"experimental": {
"allowSubAgents": true
}
}
Expected Behavior
Each task result keeps the reply of its own round — resuming a session must never rewrite the content of earlier calls' results.
Debug Context Logs
| layer | round 1 | round 2 | round 3 |
| --------------------------------- | ------------------ | ------------------ | ------------------ |
| subagent's actual replies | `ROUND-1` + answer A | `ROUND-2` + answer B | `ROUND-3` + answer C |
| task results in parent DB | A ✓ | B ✓ | C ✓ |
| task results in the model's input | C ✗ | C ✗ | C ✓ |
Tool Call Details
No response
DCP Version
3.1.14
Opencode Version
1.18.11
Bug Description
I often run multi-round work in a single subagent session (the task tool with task_id, experimental.allowSubAgents: true — a subagent on a long task needs DCP to prune its own context). Nothing looks wrong unless the model goes back and reads them. In a real session this made the main agent conclude the subagent was repeating itself, and it re-sent the same instruction byte-for-byte over and over.
Minimal reproduction
experimental.allowSubAgents: true.ROUND-1-MARKER.task_idwith two different questions, asking forROUND-2-MARKER/ROUND-3-MARKER.What I get:
ROUND-1+ answer AROUND-2+ answer BROUND-3+ answer CRoot cause in brief:
injectExtendedSubAgentResultsreplaces the whole<task_result>body with the subagent session's current last assistant text. The cache that's supposed to pin each call's correct text (subAgentResultCache) lives in DCP's singleton session state, which is reset on every session switch — and a resumed subagent runs its own model calls through the same hook between the parent's turns, so the cache is empty on every single parent call. No server restart or special environment needed; any resumed session hits this every round.Expected Behavior
Each task result keeps the reply of its own round — resuming a session must never rewrite the content of earlier calls' results.
Debug Context Logs
Tool Call Details
No response
DCP Version
3.1.14
Opencode Version
1.18.11