From a457fb75936e615674783230daef40a42c72c381 Mon Sep 17 00:00:00 2001 From: g97iulio1609 Date: Sat, 28 Feb 2026 12:18:18 +0100 Subject: [PATCH] fix: remove developer note from transfer_to_agent tool description The docstring of transfer_to_agent() included a 'Note:' section with developer-facing advice about preferring TransferToAgentTool. Since FunctionTool uses the full docstring as the tool description sent to the model on every invocation, this note was consuming input tokens and adding irrelevant information to the model context. Move the note to an inline comment in the function body so it remains visible to developers but is not included in the tool description. Fixes #4615 --- src/google/adk/tools/transfer_to_agent_tool.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/google/adk/tools/transfer_to_agent_tool.py b/src/google/adk/tools/transfer_to_agent_tool.py index 4db933999a..613358d7bc 100644 --- a/src/google/adk/tools/transfer_to_agent_tool.py +++ b/src/google/adk/tools/transfer_to_agent_tool.py @@ -29,14 +29,12 @@ def transfer_to_agent(agent_name: str, tool_context: ToolContext) -> None: 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. """ + # Developer note: For most use cases, prefer TransferToAgentTool over + # calling this function directly. TransferToAgentTool adds enum + # constraints that prevent LLMs from hallucinating invalid agent names. tool_context.actions.transfer_to_agent = agent_name