Skip to content

fix(litellm): collect all tools so native tools aren't dropped#6416

Closed
vup903 wants to merge 2 commits into
google:mainfrom
vup903:fix-issue-6091
Closed

fix(litellm): collect all tools so native tools aren't dropped#6416
vup903 wants to merge 2 commits into
google:mainfrom
vup903:fix-issue-6091

Conversation

@vup903

@vup903 vup903 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:

When ADK's LiteLlm integration is used through a proxy gateway, native/built-in tools (tools without function_declarations, e.g. google_search) are silently dropped and never reach the gateway. _get_completion_inputs gated all tool conversion on llm_request.config.tools[0].function_declarations, so:

  • a Tool carrying only native tools produced tools=None (the reported bug), and
  • any Tool past index 0 was ignored entirely — the list comprehension only ever touched tools[0], which is the underlying root cause; native-tool dropping is the most common way people hit it.

Solution:

Loop over all llm_request.config.tools instead of only index 0: convert function_declarations through the existing _function_declaration_to_tool_param path, and serialize native tools via model_dump(by_alias=True, exclude_none=True) into the same combined list. Function and native tools are always sent together; ADK does not pre-emptively guess provider support, so an unsupported schema is rejected by the provider/proxy like any other unsupported parameter (per maintainer guidance on the issue).

The identical tools[0]-only slice in _build_request_log is fixed the same way for consistency (debug-log only; does not change what is sent).

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Added to tests/unittests/models/test_litellm.py:

  • test_get_completion_inputs_serializes_native_only_tool — a native-only Tool is serialized instead of dropped.
  • test_get_completion_inputs_mixed_native_and_function_tools — both a native tool and a function tool reach the request.
  • test_get_completion_inputs_collects_tools_beyond_index_zero — function tools on config.tools[1:] are no longer ignored.
  • test_get_completion_inputs_no_tools_returns_none — regression: no tools still yields tools=None.
$ pytest tests/unittests/models/test_litellm.py -q
345 passed, 4 warnings in 16.40s

Manual End-to-End (E2E) Tests:

For the OpenAI path I ran ADK's LiteLlm against a local litellm proxy and confirmed native tools now appear in the outgoing request body (before this change the body carried no tools). I don't have a Vertex AI environment, so the Vertex-via-proxy path is covered here by wire-shape assertions against a mocked OpenAI-compatible backend — a check on a real Vertex proxy during review would be appreciated (@surajksharma07 offered a second pair of eyes on the Vertex-side wire shape).

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.

@google-cla

google-cla Bot commented Jul 17, 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 models [Component] This issue is related to model support label Jul 17, 2026
_get_completion_inputs only converted tools[0].function_declarations, so
Tools carrying only native/built-in tools (e.g. google_search) produced
tools=None and any Tool past index 0 was ignored entirely. Loop over all
config.tools instead: convert function declarations as before and serialize
native tools via model_dump(by_alias=True, exclude_none=True) into the same
list. Apply the same fix to the tools[0]-only slice in _build_request_log.

Fixes google#6091
copybara-service Bot pushed a commit that referenced this pull request Jul 17, 2026
Merge #6416

Closes #6091

PiperOrigin-RevId: 949701684
@adk-bot

adk-bot commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Thank you @vup903 for your contribution! 🎉

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

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 Jul 17, 2026
@adk-bot adk-bot closed this Jul 17, 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 models [Component] This issue is related to model support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADK bug — LiteLlm: native tools silently dropped when routing through a proxy gateway

4 participants