Repository navigation
Conversation
Bare additional_drop_params keys should only remove request-level params. Conversation history and tool payloads that reuse the same field name must stay intact so Anthropic fallback routing does not 400. Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
Greptile SummaryThe PR changes additional parameter dropping so bare names remove only top-level request fields while explicit nested paths retain their existing behavior
Confidence Score: 4/5The PR appears safe to merge after addressing the non-blocking payload typing issue The request transformation preserves conversation thinking fields while retaining explicit nested deletion, with no blocking behavioral or security failure established Files Needing Attention: litellm/litellm_core_utils/dot_notation_indexing.py, tests/test_litellm/test_nested_drop_params.py
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/dot_notation_indexing.py | Adds the shared top-level-aware drop helper; behavior is focused, but its coarse payload typing violates repository conventions |
| litellm/utils.py | Replaces nested-only deletion with the shared helper after provider parameter mapping |
| litellm/llms/custom_httpx/llm_http_handler.py | Applies the shared helper before transforming Anthropic Messages requests |
| litellm/_lazy_imports_registry.py | Registers the new helper for lazy access through litellm.utils |
| tests/test_litellm/test_nested_drop_params.py | Adds focused regression cases, with one newly introduced unparameterized dict annotation |
| tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py | Extends handler coverage to verify conversation-history thinking content survives top-level drops |
Reviews (1): Last reviewed commit: "fix(utils): keep nested thinking when dr..." | Re-trigger Greptile
There was a problem hiding this comment.
Pull request overview
This PR fixes additional_drop_params so dropping a bare key like thinking only removes the top-level request parameter, without corrupting conversation-history content blocks used by Anthropic fallbacks
Changes:
- Introduces
apply_additional_drop_params()to scope bare-key drops to the top-level request while still honoring explicit nested JSONPath drops - Wires the new drop behavior into optional params handling and the Anthropic Messages HTTP handler
- Adds regression tests covering message-history thinking blocks, tool fields named
thinking, and explicit nested drops
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_litellm/test_nested_drop_params.py | Adds focused regression tests ensuring bare drops do not strip messages[].content[].thinking |
| tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py | Extends Anthropic Messages handler regression to verify history thinking blocks survive bare drops |
| litellm/utils.py | Switches additional drop handling to apply_additional_drop_params() for consistent bare and nested behavior |
| litellm/llms/custom_httpx/llm_http_handler.py | Applies apply_additional_drop_params() before Anthropic provider transform runs |
| litellm/litellm_core_utils/dot_notation_indexing.py | Implements apply_additional_drop_params() with special handling for conversation payload keys |
| litellm/_lazy_imports_registry.py | Registers apply_additional_drop_params for lazy import resolution |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The helper is loaded through the lazy getattr path, so the TYPE_CHECKING name was an F401 that blew the strict-rule budget. Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TLDR
Problem this solves:
How it solves it:
Explicit nested paths keep their existing deletion behavior. The shared helper uses read-only Mapping and Sequence interfaces and builds each result without rebinding mutable accumulators. Both optional-parameter processing and the Anthropic Messages handler use it
User Flow
Before: reasoning history can lose fields when a fallback drops unsupported parameters
additional_drop_params: ["thinking"]After: dropping a request option preserves reasoning history
additional_drop_params: ["thinking"]Relevant issues
Fixes #37479
Validation
The branch now includes the upstream trace-contract correction for agent names and framework fields. The current required checks pass, and rust-test now passes. The optional OSV scan still reports an existing development dependency advisory
220 Python tests pass across the nested-drop and HTTP-handler files. All 114 tests in the Rust traces crate also pass, including the result-contract case that failed in the previous CI run. The repository
make checkpasses, including formatting, Ruff, strict-rule budgets, type discipline, test quality, type checking, circular imports, and import safety. Disabling bare-key deletion makes two focused regression cases failPre-Submission checklist
Type
Bug Fix
Caveats
Low
High
The dependency manifests match main. The scanner reports no fixed version for GHSA-vfj7-8cjw-p6xm. OSV is outside main's required status checks, and #44347 tracks the repository-wide exception