fix(cli): expose SendMessage tool for subagent resumption by enabling…#757
Open
Adityakk9031 wants to merge 1 commit intoanthropics:mainfrom
Open
fix(cli): expose SendMessage tool for subagent resumption by enabling…#757Adityakk9031 wants to merge 1 commit intoanthropics:mainfrom
Adityakk9031 wants to merge 1 commit intoanthropics:mainfrom
Conversation
… teams flag internally (anthropics#716)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #716
This PR resolves the issue where a long-running programmatic subagent hallucinates the
SendMessagetool 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,
SendMessageis part of the Agent Teams toolset, which is hidden behind theCLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMSflag. 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=1environment variable to the subprocess whenever programmatic agents are configured via ClaudeAgentOptions. This exposes theSendMessagetool to the model, allowing legitimate subagent resumption to succeed without errors.