Agent tool prompt parameter re-injected as next user-turn input (no user typing)
Resolved 💬 3 comments Opened May 11, 2026 by Curzibn Closed May 14, 2026
Description
Claude Code main agent receives a user-turn input whose verbatim content is identical to the prompt parameter of the immediately preceding Agent (sub-agent) tool call. The user confirmed they did not type anything. This is reproducible (user reports it has happened before).
Reproduction
- Main agent calls the
Agenttool with a short structuredprompt, e.g.:
````
task_id: .governance/projects/Koni/weekly/2026-W19/WO-20260511-003-koni-tencent-three-bugs-hotfix-redeploy.md
- Sub-agent completes and returns its result (agentId
a9475babc8fa3284f). - Main agent reports back to the user and waits for the next user turn.
- Next user turn arrives — but the content is the exact verbatim string from step 1 (
task_id: .governance/...same-path...). - User explicitly denies typing anything.
Environment
- Claude Code (CLI) main agent
- Model: claude-opus-4-7
- Custom sub-agent (
koni-devopsslug, defined in.claude/agents/) - Project has no
UserPromptSubmithook configured (onlySessionStartandPreToolUse Write|Edit)
Investigated and ruled out
- Project-side hooks: no
UserPromptSubmithook;SessionStartwrites system context only;PreToolUseruns after user turn, cannot inject one - Sub-agent return content: sub's return body does not contain a
task_id:prefixed line (only the path appears in unrelated documentation context) SendMessagemis-route: sub→main reverse direction is not supported
Suspected related issues
- #51304 — \
ScheduleWakeup\re-enters slash-command prompt on completed task. Different surface but same underlying mechanism: a tool's prompt parameter being re-injected into conversation context as user input - #30730 — sub-agent dispatch injects hardcoded post-prompt instructions, evidencing a context re-injection pipeline for \
Agent\tool prompts
Hypotheses
- Framework-side: \
Agent\tool prompt history dedupe failure — main agent's conversation history reconstruction misclassifies the prior tool-call \prompt\field as a standalone user message - Client-side: IDE / CLI history navigation key (VS Code \
Ctrl+↑\, JetBrains \Cmd+↑\, terminal \↑\) accidentally surfaces the prior \Agent\tool call's prompt as a draft user message in the input box, sent on Enter
Documentation gap
\code.claude.com/docs/en/sub-agents.md\ does not document the lifecycle of the \Agent\ tool's \prompt\ parameter on the main-agent side after the sub returns (caching, dedupe, merging behavior unspecified).
Impact
- Main agent may interpret the phantom user input as a real instruction and take action (e.g., re-dispatch a task that's already complete, mutate state, push commits)
- Defensive workaround pushed to user: every main-agent turn must check whether a structured user-input string matches a recent tool-call prompt verbatim and challenge the user before acting
Ask
- Confirm whether this is a known framework behavior or a client-side issue
- Document the \
Agent\tool \prompt\parameter lifecycle on the main side - If framework-side: consider stamping injected/replayed turns with a sentinel marker visible to the model
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗