Parent LLM ignores subagent isolation when using `@agent` references
Description
When using @agent references (e.g., @oracle) multiple times in a session, the parent LLM sends prompts assuming the subagent remembers previous calls - "continue your analysis", "refine what you said earlier". Each @agent triggers the Task tool, which creates an isolated session. The parent LLM doesn't internalize this.
task.txt:21 says "Each agent invocation is stateless..." but this doesn't register. I've seen the parent LLM send follow-up prompts with "Updated Context" and "as previously thought" - phrases that only make sense if the subagent saw the prior request.
Might be minor - the subagent usually figures it out from context, but it sometimes causes confusion.
Suggested fix
Make the instruction more prominent in task.txt:
IMPORTANT: Each @agent call creates a NEW session with NO memory. Do NOT reference "previous analysis" or assume continuity - include ALL context every time.
OpenCode version
1.0.152
Steps to reproduce
- Start a session and ask the LLM to analyze something complex
- Use @agent to call a subagent
- Ask a follow-up that requires calling the same agent again
- Observe the parent LLM sending a prompt like "Updated Context" or referencing what the subagent "previously" found
Screenshot and/or share link
https://opncd.ai/share/1igWcU6U
Operating System
Linux
Terminal
Ghostty
This issue might be a duplicate of existing issues. Please check:
- #2390: Switching to a child session doesn't send subsequent messages to that session but to the parent one - describes the parent LLM continuing to interact with the parent session instead of the subagent
- #4483: Subagents inappropriately inherit main agent instructions from CLAUDE.md/AGENTS.md - describes context pollution between parent and subagents
- #4422: Primary agent responds in subagent view; delegated subagent views become inaccessible - related issue with parent/subagent context confusion
Feel free to ignore if none of these address your specific case.
Not a duplicate. Those issues are about UI routing (#2390, #4422) or config inheritance (#4483). This is about the parent LLM's understanding of subagent isolation - it generates prompts assuming continuity ("Updated Context", "as previously thought") when each subagent call is stateless.
There is this part here so they aren't stateless in this case, perhaps we should reword it:
unless you provide a session_id.
There is this part here so they aren't stateless in this case, perhaps we should reword it:
unless you provide a session_id.
Yeah, I'm totally oblivious on the "art" of prompting given how fast things are changing these days -- but I would assume some **bold** or UPPERCASE callouts might help? I don't mind opening a PR to get the ball rolling, assuming there's interest in pursuing some sort of tweak to the wording.
I guess some helpful info:
what model were u using?
can you share anything about your oracle agent?
can you share the session where this happened?
Sure! I was using a mixture of Sonnet 4.5 and Opus 4.5 -- though I think primarily Opus was the one calling the subagent.
The oracle agent basically straight lifted from the Amp Code agent of the same name. I found a prompt here and also saw a version of it in the Oh My OpenCode codebase. I used GPT-5.2 as the model for the subagent oracle.
I shared the session in my initial description, but for some reason the page is blank when I try to load it:
Screenshot and/or share link
Looking in the console I see logs that show the actual chat.
After having a sleep on it, I think I'm just going to do some tinkering with overriding the task tool with a custom tool and see if anything comes from that. I'll go ahead and close this to reduce the issue noise in the repo. Thanks for taking the time to reply!