fix(llm): filter internal params at provider request boundaries - #41025
fix(llm): filter internal params at provider request boundaries#41025fangkangmi wants to merge 3 commits into
Conversation
Revive the implementation from PR BerriAI#30774 by Mateo Wang on current main. Preserve async transforms, fallback controls and request signing, and prevent extra_body from reintroducing internal embedding parameters.
|
bugbot run Please review this continuation of #30774, including asynchronous transforms, request signing, embedding filtering, and preserved caching behaviour |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR filters LiteLLM-only parameters at provider request boundaries while preserving parameters that transforms must consume before serialization.
Confidence Score: 5/5The PR appears safe to merge; no actionable regressions or outstanding previous findings remain. The latest changes successfully move filtering into a standard-library-only utility module without leaving stale repository imports or creating an import cycle. The previously reported Nova caching regression is fixed by preserving cache injection points through transformation and stripping them afterward, and the redundant test comments have been removed.
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/internal_params.py | Defines a dependency-light registry and filtering helpers for removing internal parameters at request boundaries. |
| litellm/llms/custom_httpx/llm_http_handler.py | Filters internal parameters around synchronous and asynchronous transforms, embedding body merges, signing, and logging boundaries. |
| litellm/llms/custom_httpx/aiohttp_handler.py | Applies equivalent pre-transform and post-transform filtering in the aiohttp completion path. |
| litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py | Sanitizes Bedrock Invoke parameters while retaining cache injection points until Nova and other delegated transforms consume them. |
| litellm/llms/bedrock/embed/embedding.py | Prevents internal optional parameters from entering Bedrock embedding request bodies. |
| tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py | Covers filtering before signing across sync and async transforms, cache preservation, and embedding extra-body merging. |
Reviews (3): Last reviewed commit: "fix(llm): isolate request filters from p..." | Re-trigger Greptile
|
@greptileai Please review the latest tip: Nova Invoke caching now survives transformation, regression coverage was added, and redundant comments were removed |
|
bugbot run Please review this continuation of #30774, including asynchronous transforms, request signing, embedding filtering, and preserved caching behaviour |
|
@greptileai Please re-review the latest tip: filtering now lives in an independent module, removing CodeQL import cycles while preserving tested behaviour |
|
bugbot run Please review this continuation of #30774, including asynchronous transforms, request signing, embedding filtering, and preserved caching behaviour |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 9e1c16b. Configure here.
TLDR
Problem this solves:
How it solves it:
Continues Mateo Wang's implementation in #30774 on current
main. I cannot push to that upstream branch. This version resolves its conflicts, handles the newer asynchronous transform path, preserves Nova Invoke tool caching, and prevents embeddingextra_bodyfrom reintroducing internal keysUser Flow
Before: requests carrying internal parameters fail against Bedrock
cache_control_injection_pointsskip_mcp_handlerAfter: the same payloads return embeddings and a completion
Relevant issues
Fixes #30371
Fixes #30314
Addresses #30301
Continues #30774
Affected release
Linear ticket
Pre-Submission checklist
Local validation at
9e1c16ba57: 600 affected tests passed, the complete repository quality gate passed, and four fresh-process import-order checks passed. Filters now live in an independent utility module to remove the provider import cycles reported by CodeQL. All 27 required CI contexts pass. Patch coverage is 93.18% against an 80.91% target. Greptile scored this tip 5/5; Bugbot and Veria found no issues. CodeQL and its Python analysis pass with no new alerts. The separate OSV dependency finding is documented belowScreenshots / Proof of Fix
Real Bedrock calls through local proxies on 14 September 2026, using bearer-token credentials supplied through the environment. No mocked provider responses. Both proxies use this configuration:
The payloads intentionally use
allowed_openai_paramsto exercise the provider boundary with internal keys present, matching the original PR's reproductionBefore (30f33a9)
Titan embeddings
Mistral Invoke chat
After (9e1c16b)
Titan embeddings
4018prompt_tokens: 3,total_tokens: 3Mistral Invoke chat
4018{ "choices": [ { "finish_reason": "length", "message": { "content": "\nHello there! How's your day going? Is there anything specific you'd like to", "role": "assistant" } } ], "usage": { "completion_tokens": 20, "prompt_tokens": 13, "total_tokens": 33 } }Type
Bug Fix
Caveats (if any)
Medium
The OSV run reports
PYSEC-2026-3865/GHSA-h7x2-h6g9-p789, with no fixed version listed.uv.lock, the dashboard lockfile, andosv-scanner.tomlhave identical Git blob IDs atmainand this PR tip. This is an existing dependency finding, not a passed check; no vulnerability ignores or dependencies were changedLow
Nova tool-cache preservation has regression coverage; no live Nova caching measurement
Legacy handlers outside these boundaries are not comprehensively audited
Live verification covers Bedrock chat and embeddings; other paths have unit coverage
Historical reviews on fix(llm): strip LiteLLM-internal optional_params from provider request bodies #30774 do not validate this new tip
Generated API types remove two stale documentation lines
Final Attestation