feat: Add tool_choice config to LlmAgent for controlling tool invocation#5984
feat: Add tool_choice config to LlmAgent for controlling tool invocation#5984Oxygen56 wants to merge 3 commits into
Conversation
|
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. |
|
Response from ADK Triaging Agent Hello @Oxygen56, thank you for creating this PR to add This is a great feature, but to help us review and merge your contribution, could you please address the following items according to our contribution guidelines:
These details will help our reviewers process your PR much faster. Thank you! |
|
Hi @Oxygen56 , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you! |
Adds a provider-agnostic 'tool_choice' field to LlmAgent that maps to provider-specific tool configuration: - 'auto' (default): Model decides whether to call tools - 'required': Model MUST call at least one tool before responding — prevents hallucinated responses when tools are available - 'none': Model MUST NOT call any tools The mapping to Google GenAI's ToolConfig/FunctionCallingConfig happens in base_llm_flow.py's _call_llm_async method, which already handles request configuration. LiteLLM and other providers can add their own mappings in their respective LLM implementations. Fixes google#773
053d9cc to
75bb20b
Compare
🔍 ADK Pull Request Analysis: PR #5984Title: 🛑 Compliance Refusal: Contributor License Agreement (CLA) Not SignedUnder Google's open-source compliance guidelines and the ADK project development workflow, we are strictly prohibited from performing code analysis, triage, diff evaluation, or any workspace operations on pull requests where the contributor has not signed the Google Contributor License Agreement (CLA). Based on our verification, the Google CLA check for this PR is currently failing:
Next Steps for the ContributorTo proceed with the review and potential merge of this Pull Request, please:
|
|
@adk-bot CLA has been signed. Ready for re-review. |
Summary
Adds a
tool_choicefield toLlmAgentthat maps provider-agnostic values (auto,required,none) to Google GenAI'sToolConfig/FunctionCallingConfig.Changes
llm_agent.py:tool_choicefield with Literal type and docstringbase_llm_flow.py: Mapstool_choice→types.ToolConfig(function_calling_config=...)tests/unittests/agents/test_tool_choice.py: 8 unit testsTesting Plan
Tests cover:
tool_choice="required"→FunctionCallingConfigMode.ANYtool_choice="none"→FunctionCallingConfigMode.NONEtool_choice="auto"/ unset → no config forced🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com