litellm/tests/unit/rust_bridge/AGENTS.md
yujonglee 55c8ec4647
refactor(rust-bridge): move the route host modules under host/routes (#46786)
* refactor(rust-bridge): move the route host modules under host/routes

Each native route's Python half lived in its own `<route>/route_host.py`, apart
from the shared host modules Rust also imports by name. They now sit together in
`litellm/rust_bridge/host/routes/<route>.py`, with their unit tests moved to the
mirrored path. No behavior change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(rust-host): reference messages route alias

Co-Authored-By: yujonglee.dev@gmail.com <yujong@berri.ai>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-15 18:27:06 -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 host/routes/<route>.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. host/routes/test_messages.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