Skip to content

Commit 2a0b4e7

Browse files
stakeswkyboyangsvl
authored andcommitted
fix: remove developer notes from transfer_to_agent docstring
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
1 parent 0d20b7c commit 2a0b4e7

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/google/adk/tools/transfer_to_agent_tool.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323
from .tool_context import ToolContext
2424

2525

26+
# Note:
27+
# For most use cases, you should use TransferToAgentTool instead of this
28+
# function directly. TransferToAgentTool provides additional enum constraints
29+
# that prevent LLMs from hallucinating invalid agent names.
2630
def transfer_to_agent(agent_name: str, tool_context: ToolContext) -> None:
2731
"""Transfer the question to another agent.
2832
29-
This tool hands off control to another agent when it's more suitable to
33+
Use this tool to hand off control to another agent that is more suitable to
3034
answer the user's question according to the agent's description.
3135
32-
Note:
33-
For most use cases, you should use TransferToAgentTool instead of this
34-
function directly. TransferToAgentTool provides additional enum constraints
35-
that prevent LLMs from hallucinating invalid agent names.
36-
3736
Args:
3837
agent_name: the agent name to transfer to.
3938
"""

0 commit comments

Comments
 (0)