[BUG] TaskOutput incorrectly returns <retrieval_status>timeout</retrieval_status> immediately upon background agent completion
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using the Claude Code agentic framework to spawn multiple background sub-agents, there is a serious synchronization bug between the background task runner and the TaskOutput tool.
Specifically, exactly at the millisecond a background sub-agent successfully finishes its execution, the blocking TaskOutput tool returns a <retrieval_status>timeout</retrieval_status> error to the main orchestrator LLM instead of returning the correct result payload.
What Should Happen?
Expected Behavior
The TaskOutput tool should cleanly resolve and return the actual <result> payload generated by the completed sub-agent to the main LLM.
Actual Behavior
The TaskOutput tool instantly resolves with a false error: <retrieval_status>timeout</retrieval_status>.
Subsequently, the background runner's queue processor asynchronously injects a successful <task-notification> (containing the true result) into the conversation history.
This creates a race condition / context confusion where the main model simultaneously sees a timeout tool failure and a successful injected notification, often leading the orchestrator to incorrectly assume the entire task failed.
Error Messages/Logs
Used 6 tools
Used 6 tools
TaskOutput
<retrieval_status>timeout</retrieval_status>
TaskOutput
<retrieval_status>timeout</retrieval_status>
TaskOutput
<retrieval_status>timeout</retrieval_status>
TaskOutput
<retrieval_status>timeout</retrieval_status>
TaskOutput
<retrieval_status>timeout</retrieval_status>
TaskOutput
<retrieval_status>timeout</retrieval_status>
Show less
Steps to Reproduce
Initiate several background sub-agents to perform code generation tasks concurrently.
The main orchestrator uses the TaskOutput tool with block: true and a long timeout (e.g., 600000ms) to wait for the sub-agent's response.
Observe the outputs when the sub-agent successfully completes its work (e.g., writing the requested files to disk) within the initial timeout limit.
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Desktop App for Windows Version 1.1.7714 (3bd6f6)
Platform
Other
Operating System
Windows
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗