-
Notifications
You must be signed in to change notification settings - Fork 862
fix(tools): allow transfer_to_agent to accept extra kwargs #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(tools): allow transfer_to_agent to accept extra kwargs #466
Conversation
transfer_to_agent now takes **kwargs to swallow unexpected keyword args Added integration tests covering single and multiple extra kwargs. Fixes google#458.
Thanks for the PR! But I think this is not the way to go. Model shouldn't be passing A better approach could be improving the docstring, which will be in the prompt. |
…usage Revert the earlier **kwargs change so transfer_to_agent again only accepts (agent_name, tool_context). Improve the doc-string to make clear that no other parameters should be passed to this tool. Fixes google#458
Thanks @Jacksunwei for the feedback! I’ve removed the |
LLM prompt or tool_context, not passed as extra parameters here. | ||
|
||
Args: | ||
agent_name: The identifier of the agent to transfer to (e.g. "math_agent"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove math_agent to avoid confusing LLM.
|
||
Args: | ||
agent_name: The identifier of the agent to transfer to (e.g. "math_agent"). | ||
tool_context: The current ToolContext, whose `actions.transfer_to_agent` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tool_context is not for LLM use, so we don't want to mention it.
LLM prompt or tool_context, not passed as extra parameters here. | ||
|
||
Args: | ||
agent_name: The identifier of the agent to transfer to (e.g. "math_agent"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/identifier/name.
tool_context: The current ToolContext, whose `actions.transfer_to_agent` | ||
field will be set. | ||
|
||
Returns: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just remove returns section, since there is none.
"""Transfer the question to another agent.""" | ||
"""Transfer the current request to another agent. | ||
|
||
This tool hands off control to a different named agent. Any additional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are likely not useful to LLM, for prompt, it's better to be direct and concise.
Fixes: #458
Background
When an LLM‐driven agent called
transfer_to_agent
with extra parameters (e.g.query
,temperature
), the tool raised:because its signature only accepted
agent_name
andtool_context
.With this change, we:
src/google/adk/tools/transfer_to_agent_tool.py
to:kwargs
are silently ignored.tests/integration/tools/test_transfer.py
to include:query
)query
,temperature
,max_tokens
)Each test is parametrized to run against both the GOOGLE_AI and VERTEX backends.
Test Plan
Checklist
Next Steps / TODO
@hangfei @Jacksunwei
Per the existing TODO comment in
transfer_to_agent_tool.py
, we could further internalize this tool (e.g. rename to_transfer_to_agent
or move into aninternal/
submodule) so it doesn’t leak into the public API.I can work on that. Let me know if I can / should?