anthropics / anthropics/claude-agent-sdk-python
Bug: Long-running subagent returns agentId with SendMessage hint, but SendMessage tool does not exist
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 1.3k
- Avg merge
- 2d 31m
- Merged PRs (30d)
- 1
Description
**SDK version:** claude-agent-sdk 0.1.50 (Python)
**Description**
When a long-running subagent completes (or is cut off by token/turn limits), its final output includes a hint:
```json
[
{
"type": "text",
"text": "The uploaded file \"chat-test-upload.txt\" (25 B) is visible in the Chat Uploads scope under `.upload/` folder. Let me take screenshot 7."
},
{
"type": "text",
"text": "agentId: a56c67d5f6d516271 (use SendMessage with to: 'a56c67d5f6d516271' to continue this agent)\ntotal_tokens: 55449\ntool_uses: 44\nduration_ms: 315536"
}
]
```
The parent agent then attempts to call `SendMessage`:
```json
{
"to": "a56c67d5f6d516271",
"message": "..."
}
```
Which fails:
```
Error: No such tool available: SendMessage
```
`SendMessage` does not exist in the SDK toolset, is not documented, and has zero references in the repo source code. The hint text is generated by Claude Code CLI internally, and the parent agent treats it as a real tool instruction.
**Steps to reproduce**
1. Spawn a subagent via the `Agent` tool with a task that takes many turns (40+ tool uses)
2. Subagent returns with the `agentId: ... (use SendMessage ...)` footer
3. Parent agent's next turn calls `SendMessage` -> `tool_use_error`
**Expected behavior**
One of:
- (a) `SendMessage` actually exists and works — subagent sessions can be resumed
- (b) The `agentId` hint is not emitted if the tool doesn't exist, preventing hallucinated tool calls
- (c) SDK provides a documented mechanism to resume/continue a subagent session (e.g. `query(resume=session_id)`)
**Actual behavior**
Parent agent enters a failure loop trying to call a non-existent tool, losing the subagent's work.
**Workaround**
None clean. The subagent must complete all work (including writing output files) before its session ends. If it gets cut off, results are lost.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the SDK's Agent tool and the query(resume=session_id) mechanism described in the issue, then compare them with the Claude Code CLI-generated agentId footer and SendMessage hint. Done means the SDK no longer leads the parent into an unsupported SendMessage call, or provides a documented, working way to resume the subagent session.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100