adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Missing LiteLlm usage_metadata.cached_content_token_count

Open stefanjacobs opened this issue 1 year ago • 3 comments

Describe the bug

Using Azure models, the cached_content_token_count is logged, when turning on debug logging in litellm. In python-adk the usage_metadata section for caching is not populated.

To Reproduce

  • Configure a model: e.g. LiteLlm( model="azure/gpt-4.1" )
  • Use the model for an agent with a prompt with at least 2000 tokens two times
  • When using the agent the second time the usage_metadata.cached_content_token_count should be filled, but is null at the moment. (I do not want to spam this issue with 2000 tokens....)

Expected behavior I would like to see the usage_metadata filled with the correct data to make valid cost estimates at runtime.

Screenshots nothing to screenshot here besides debugger sessions with None objects...

Desktop (please complete the following information):

  • OS: macOS
  • Python version(python -V): 3.13.7
  • ADK version(pip show google-adk): 1.15.1

Model Information:

  • Are you using LiteLLM: Yes
  • Which model is being used: Azure GPT4.1 mostly

Additional context

The problem is probably at these lines:

  • https://github.com/google/adk-python/blob/main/src/google/adk/models/lite_llm.py#L466
  • https://github.com/google/adk-python/blob/main/src/google/adk/models/lite_llm.py#L494
  • https://github.com/google/adk-python/blob/main/src/google/adk/models/lite_llm.py#L873 where the cached token usage is not set.

stefanjacobs avatar Sep 30 '25 09:09 stefanjacobs

I’d like to work on this.

omerfarukeskin01 avatar Oct 04 '25 18:10 omerfarukeskin01

@lizzij will take a look at this issue.

lizzij avatar Oct 27 '25 16:10 lizzij

Fixed now. Thanks you all!

hangfei avatar Nov 04 '25 20:11 hangfei