Skip to content

fix: remove developer notes from transfer_to_agent docstring#4617

Closed
stakeswky wants to merge 2 commits into
google:mainfrom
stakeswky:fix/transfer-to-agent-docstring-cleanup
Closed

fix: remove developer notes from transfer_to_agent docstring#4617
stakeswky wants to merge 2 commits into
google:mainfrom
stakeswky:fix/transfer-to-agent-docstring-cleanup

Conversation

@stakeswky

Copy link
Copy Markdown
Contributor

Summary

Fixes #4615

The transfer_to_agent function's docstring included a Note section with developer guidance about using TransferToAgentTool instead. Since this docstring is sent to the model as the tool description on every invocation, the extra text wastes input tokens and increases hallucination risk.

Before

description: "Transfer the question to another agent. This tool hands off control to another agent when it's more suitable to answer the user's question according to the agent's description. Note: For most use cases, you should use TransferToAgentTool instead of this function directly. TransferToAgentTool provides additional enum constraints that prevent LLMs from hallucinating invalid agent names. Args: agent_name: the agent name to transfer to."

After

description: "Transfer the question to another agent. Use this tool to hand off control to another agent that is more suitable to answer the user's question according to the agent's description. Args: agent_name: the agent name to transfer to."

Changes

  • src/google/adk/tools/transfer_to_agent_tool.py: Removed the Note section from the docstring, keeping only the model-facing description and Args.

Testing

All 9 existing tests in test_transfer_to_agent_tool.py pass, including test_transfer_to_agent_tool_preserves_description which validates the tool description content.

The function docstring included a Note section with developer guidance
about using TransferToAgentTool instead. Since this docstring is sent
to the model as the tool description on every invocation, the extra
text wastes input tokens and increases hallucination risk.

Removed the Note section while keeping the user-facing description
and Args documentation intact.

Fixes google#4615
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@google-cla

google-cla Bot commented Feb 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Feb 25, 2026
@stakeswky stakeswky force-pushed the fix/transfer-to-agent-docstring-cleanup branch from 91c0ea6 to 404cb23 Compare February 25, 2026 04:16
@rohityan rohityan self-assigned this Feb 26, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @stakeswky , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.

@rohityan

Copy link
Copy Markdown
Collaborator

Hi @xuanyang15 , can you please review this.

@rohityan rohityan added the needs review [Status] The PR/issue is awaiting review from the maintainer label Feb 27, 2026
@xuanyang15 xuanyang15 self-assigned this Feb 28, 2026
Signed-off-by: stakeswky <stakeswky@gmail.com>
@stakeswky stakeswky force-pushed the fix/transfer-to-agent-docstring-cleanup branch from ca8ae7b to 4c78693 Compare February 28, 2026 04:17
@wuliang229 wuliang229 assigned wuliang229 and unassigned xuanyang15 and rohityan Apr 16, 2026
@boyangsvl boyangsvl self-assigned this Jun 11, 2026
copybara-service Bot pushed a commit that referenced this pull request Jun 11, 2026
Merge #4617

## Summary

Fixes #4615

The `transfer_to_agent` function's docstring included a `Note` section with developer guidance about using `TransferToAgentTool` instead. Since this docstring is sent to the model as the tool description on every invocation, the extra text wastes input tokens and increases hallucination risk.

## Before

```
description: "Transfer the question to another agent. This tool hands off control to another agent when it's more suitable to answer the user's question according to the agent's description. Note: For most use cases, you should use TransferToAgentTool instead of this function directly. TransferToAgentTool provides additional enum constraints that prevent LLMs from hallucinating invalid agent names. Args: agent_name: the agent name to transfer to."
```

## After

```
description: "Transfer the question to another agent. Use this tool to hand off control to another agent that is more suitable to answer the user's question according to the agent's description. Args: agent_name: the agent name to transfer to."
```

## Changes

- `src/google/adk/tools/transfer_to_agent_tool.py`: Removed the `Note` section from the docstring, keeping only the model-facing description and Args.

## Testing

All 9 existing tests in `test_transfer_to_agent_tool.py` pass, including `test_transfer_to_agent_tool_preserves_description` which validates the tool description content.

Co-authored-by: Bo Yang <ybo@google.com>
COPYBARA_INTEGRATE_REVIEW=#4617 from stakeswky:fix/transfer-to-agent-docstring-cleanup 4c78693
PiperOrigin-RevId: 930320693
@adk-bot

adk-bot commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Thank you @stakeswky for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 2a0b4e7.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Jun 11, 2026
@adk-bot adk-bot closed this Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged needs review [Status] The PR/issue is awaiting review from the maintainer tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change the docstring for the transfer_to_agent tool to remove unneeded information sent to the model.

6 participants