Skip to content

fix(cli): expose SendMessage tool for subagent resumption by enabling…#757

Open
Adityakk9031 wants to merge 1 commit intoanthropics:mainfrom
Adityakk9031:#716
Open

fix(cli): expose SendMessage tool for subagent resumption by enabling…#757
Adityakk9031 wants to merge 1 commit intoanthropics:mainfrom
Adityakk9031:#716

Conversation

@Adityakk9031
Copy link
Copy Markdown

@Adityakk9031 Adityakk9031 commented Mar 27, 2026

Description

Fixes #716
This PR resolves the issue where a long-running programmatic subagent hallucinates the SendMessage tool upon completion, causing the parent agent to enter a failure loop.
Root Cause:
When a subagent completes, the Claude Code CLI appends a resumption hint (use SendMessage with to: '...' to continue this agent). However, SendMessage is part of the Agent Teams toolset, which is hidden behind the CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS flag. Because this flag is off by default, the parent agent receives a <tool_use_error>.
Fix:
Because the parent agent tool loop executes within the CLI subprocess, the cleanest solution is to proactively inject the CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 environment variable to the subprocess whenever programmatic agents are configured via ClaudeAgentOptions. This exposes the SendMessage tool to the model, allowing legitimate subagent resumption to succeed without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Long-running subagent returns agentId with SendMessage hint, but SendMessage tool does not exist

1 participant