Skip to content

fix(extensions): forward empty extra_query and metadata in LiteLLM path - #4588

Closed
weike-zhang wants to merge 1 commit into
openai:mainfrom
weike-zhang:fix/litellm-empty-extra-query-metadata
Closed

fix(extensions): forward empty extra_query and metadata in LiteLLM path#4588
weike-zhang wants to merge 1 commit into
openai:mainfrom
weike-zhang:fix/litellm-empty-extra-query-metadata

Conversation

@weike-zhang

Copy link
Copy Markdown
Contributor

Summary

LitellmModel drops an explicitly-configured empty extra_query / metadata dict before calling litellm.acompletion, because it uses falsy checks (if model_settings.extra_query:) instead of is not None checks. This diverges from the other two model paths:

Change

Use is not None checks for extra_query and metadata in the LiteLLM chat path, matching #4544's handling in the AnyLLM path. Empty dicts are now forwarded instead of silently discarded.

Verification

  • Added a regression test (test_empty_extra_query_and_metadata_are_forwarded) that mocks litellm.acompletion and asserts extra_query={} and metadata={} reach the provider. Confirmed it fails (KeyError: 'extra_query') before the fix and passes after.
  • ruff check / ruff format --check clean on both touched files.
  • Related LiteLLM tests pass (test_litellm_extra_body.py, test_litellm_content_filter.py, test_litellm_usage_requests.py — 16 passed).

@seratch

seratch commented Aug 22, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution. I confirmed that LitellmModel currently omits empty extra_query and metadata mappings, but I could not find a supported behavior that changes when those empty mappings are passed to litellm.acompletion. ModelSettings resolution already accepts {} as an explicit override, so it can clear inherited values; after that, omitting the empty mapping produces the same request outcome. The new test only locks the adapter-to-LiteLLM call shape, while #4544's empty-mapping assertions were incidental to its extra_body fix and do not establish a separate need here.

I am going to close this PR. If there is a concrete LiteLLM provider or supported callback for which omission and {} produce different user-visible behavior, please share that scenario and we can reconsider the narrower requirement.

@seratch seratch closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants