You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Resuming a subagent via task_id silently rewrites all previous task results with the latest reply #595
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.
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 ✓ |
I'm not really sure if this counts as a feature, so I'm opening this issue for now. If it is a feature, then this issue can just be closed (I'll maintain my own branch). This is a really useful plugin—thanks to the maintainers!
Activity
jensenojs commentedon Aug 4, 2026
I'm not really sure if this counts as a feature, so I'm opening this issue for now. If it is a feature, then this issue can just be closed (I'll maintain my own branch). This is a really useful plugin—thanks to the maintainers!
@LeXwDeX