Skip to content

Add monkey patching for ADK's litellm import#1660

Draft
saglave wants to merge 1 commit intoNVIDIA:developfrom
snps-scm13:snps/adk-llm-wrap-fix
Draft

Add monkey patching for ADK's litellm import#1660
saglave wants to merge 1 commit intoNVIDIA:developfrom
snps-scm13:snps/adk-llm-wrap-fix

Conversation

@saglave
Copy link
Contributor

@saglave saglave commented Feb 25, 2026

Description

The ADKProfilerHandler monkey patch for litellm.acompletion works usually intercepts LLM calls made through litellm. But depending on how NAT and ADK are initiated, this would at times fail.

Root Cause
Google ADK's lite_llm.py uses a direct import of acompletion

This creates a local reference in the ADK module's namespace. When the profiler patched litellm.acompletion, it only modified the reference in the litellm module, not the local copy that ADK already had.

Since LiteLLMClient.acompletion() calls the local acompletion, it bypassed the monkey patch entirely.

This fix adds monkey-patching for google.adk.models.lite_llm.acompletion alongside the existing litellm.acompletion to ensure that the calls are always intercepted.

Closes

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Signed-off-by: Sangharsh Aglave <aglave@synopsys.com>
@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 25, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@willkill07
Copy link
Member

@saglave when this is ready for review could you retarget the release/1.5 branch by cherry-picking this onto release/1.5 and setting the target branch on github to release/1.5 ?

@saglave
Copy link
Contributor Author

saglave commented Mar 5, 2026

@willkill07 Sure. Will do so. Just running some tests to make sure that the LLM calls aren't logged twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants