litellm/tests/unit/rust_bridge/AGENTS.md
yujonglee 2aaa0b5d5c
refactor(rust-bridge): unify native call inputs and Messages settings (#45126)
* refactor(rust): separate Messages settings from capability inputs

* refactor(rust-bridge): unify Messages OCR and Responses call inputs

* refactor(rust-bridge): share NativeCall across inference entrypoints

* fix(rust-bridge): preserve Responses URL aliases and public test inputs
2026-10-07 15:05:43 -07:00

2 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.responses.main.responses. The Rust path is the native binding, e.g. NATIVE_OCR.load() from litellm/rust_bridge/ocr/entrypoints.py, called with the NativeCall envelope that dispatch would hand it for every public inference route. 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