Proof Portal
litellm
BerriAI117 findings · 107 requirementsLiteLLM Python->Rust migration audit (proof mirroring).
Python->Rust divergence: Rust Azure messages folds ALL role=system messages unconditionally, ignoring supports_mid_conversation_system
Medium-severity issue, currently open.
How well is this finding proven?
- 1.Reported / candidate
Complete
- 2.Reproducer written
Complete
View reproducer - 3.Reproduces (recorded run)
Not yet established
View evidence - 4.Independently re-run
Not yet established
- 5.Meets quality standard
Not assessed
- 6.Validated for submission
Not assessed
Recorded runs show whether the issue reproduces. Independent re-runs are shown separately. A later review does not fill in a missing earlier step.
Description
The issue as recorded.
Cross-language parity finding for MIR-008. The Python AzureAnthropicMessagesConfig.transform_anthropic_messages_request calls _normalize_system_role_messages (litellm/llms/anthropic/experimental_pass_through/messages/transformation.py:161), which for models flagged supports_mid_conversation_system in the cost map (Claude 4.8+ and the 5 family) hoists ONLY a leading run of role=system messages and KEEPS a mid-conversation system entry in place (hoisting it would mutate the system prefix and invalidate the prompt cache for the whole history). The Rust fold_system_role_messages (litellm-rust/crates/core/src/providers/azure_ai/messages/transformation.rs:118) partitions on role==system and folds EVERY system-role message unconditionally, with no supports_mid_conversation_system gating. For a supported model carrying a mid-conversation system reminder, the Rust path hoists it into the top-level system prefix - a different request body than Python and a prompt-cache invalidation. The 7R3W fold behavior is reproduced only for the always-hoist (older-model) case; the mid-conversation-keep case has no Rust counterpart.
Affected requirements
The requirement(s) this issue violates — click through to the spec.
Port parity
How this finding relates to the port: whether the behaviour diverges, isn't ported yet, was fixed, or matches across both implementations.
- Azure AI messages: Python -> RustMIR-008Defect in the Rust port itselfPython → RustView in Mirrors
Severity, explained
Why this is rated the way it is — and the scoring signals behind the rating (each ⓘ explains the term).
- why this rating
- Risk-rated
- risk area
- Correctness
Where it is
The code the issue lives in — peek the affected function inline to see it in context.
- providers::azure_ai::messages::transformation::fold_system_role_messages (Rust) vs AnthropicMessagesConfig._normalize_system_role_messages called from AzureAnthropicMessagesConfig.transform_anthropic_messages_request (Python)
Reproducer and evidence
The recorded reproducer and its evidence-run outcome. Inspect the test and source, or run the command to check the behavior yourself.
// Reproduces: markercargo test -p litellm-core --lib providers::azure_ai::messages::transformation::tests::transform_request_folds_mid_conversation_system_even_for_supported_model (characterizes the unconditional fold - a mid-conversation role=system message on claude-opus-4-8 is hoisted into top-level system; passes now, flips once the fold is gated on supports_mid_conversation_system and leaves the entry in messages like Python)
Reproduction steps
Technical steps for your engineers to confirm the issue by hand.
cargo test -p litellm-core --lib providers::azure_ai::messages::transformation::tests::transform_request_folds_mid_conversation_system_even_for_supported_model (characterizes the unconditional fold - a mid-conversation role=system message on claude-opus-4-8 is hoisted into top-level system; passes now, flips once the fold is gated on supports_mid_conversation_system and leaves the entry in messages like Python)
How it can be triggered
The input or condition that sets this issue off.
a mid-conversation role=system message on a model flagged supports_mid_conversation_system (e.g. Claude 4.8+/5 family)
What protects you, and the fix
What limits your exposure today, and the planned remediation.
What protects you now
Gate the Rust fold on the model's supports_mid_conversation_system capability (as the Python normalizer does) before hoisting mid-conversation system entries.
The fix
Port the supports_mid_conversation_system branch into fold_system_role_messages: hoist only the leading run for supported models and leave mid-conversation system entries in place; add a Rust test asserting a mid-conversation system message is NOT hoisted for a supported model.
Blast radius
If you touch this issue, what else may need re-checking — the requirements it affects and the code and tests that hang off them. Historical view: authored trace links only — automatically derived links aren't reconstructible for past runs.
Touch this finding and you re-check 1 requirements · 2 code files · 0 tests.
- transformation.rs
- messages_transformation.py
Per-requirement evidence
For each requirement this finding touches: the implementing code, verifying tests, and proof obligations that discharge it.
Per-requirement evidence
For each requirement this finding touches: the implementing code, verifying tests, and proof obligations that discharge it.
Change history
Every recorded revision of this finding's source file — when it was added, edited, or re-classified, with the diff for each change.
Discussions
Discuss this with the proof team. Nothing changes in your audit automatically — you open a request and a staff member records any outcome inside the thread.