The Rust Messages route only relayed the body. It now runs the request shaping the Python handler does for the direct Anthropic provider: history sanitizers (empty blocks, tool ids, replayed web search results, provider_specific_fields, encrypted reasoning, advisor blocks), reasoning_effort and adaptive/legacy thinking translation against the model's capability flags, the sampling and speed gates under drop_params, the metadata allowlist, additional_drop_params, reasoning auto summary, OAuth and ANTHROPIC_AUTH_TOKEN credentials, provider_specific_header merging and anthropic-beta injection. Capability flags and LiteLLM settings reach Rust through route_host.shaping(). A request the route rejects before the call now maps to BadRequestError instead of APIConnectionError Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1.9 KiB
Rust bridge tests
Test what each side of the bridge does, not the rollout policy that picks a side. LITELLM_RUST and catalog.RULES change every time a route or backend rolls forward, so a test that sets the env var or patches the catalog to reach a path goes red on a policy change even when the code under test is fine
Call each path directly with an explicit decision instead. The Python path is the implementation the dispatcher falls back to, e.g. litellm.ocr.main.ocr. The Rust path is the native binding, e.g. NATIVE_OCR.load() from litellm/rust_bridge/ocr/entrypoints.py, called with the request, args and kwargs that dispatch would hand it. When the native side reads a policy-derived setting such as settings.secret_manager().native, pin that field in the test instead of deriving it from the catalog. ocr/test_secrets.py shows the pattern
Rollout policy itself, meaning which rule matches and what LITELLM_RUST changes, belongs in test_catalog.py, test_configuration.py and test_dispatch.py, tested against rules the test builds rather than the shipped catalog.RULES
Before adding a test here, ask whether it checks something Rust cannot. A route_host.py module is the Python half of a native route: it projects Python-only state (the cost map, litellm.* settings, request kwargs) into the plain values the Rust side consumes, and maps native failures back onto public exceptions. Those projections are what belongs here, because a wrong key or an ignored provider prefix ships the wrong value to Rust and no Rust test sees it. messages/test_route_host.py shows the shape. Behavior that lives in Rust (a request transform given its inputs, header assembly, stream relay) is tested in the crate, and the route end to end is tested against a recording server in tests/test_litellm_rust/. A test that only re-checks a Python helper the route host happens to call is a duplicate of that helper's own test and should not be added