litellm/tests/unit/rust_bridge
Yujong Lee 2c08938d78 feat(rust): run body hooks on native streams
Python's Messages handler holds a provider stream back when the request
carries a tool a registered callback fulfils server-side, runs the
agentic hooks on the assembled message, and streams what came out, so
the tool call never reaches a client that cannot run it. It also turns
a complete response back into a stream when a pre-request hook made the
provider call complete for a caller who asked to stream. The native
route relayed every stream live and ran no response hooks on it

Add a route-neutral StreamPolicy stage to the host hook contract. The
driver opens the caller's stream at once under HoldBack, swallows the
provider's chunks, assembles them through the binding at stream end,
runs transform_response, and replays the result chunk by chunk, and
Synthesize replays a complete response the same way. While a held-back
call waits on the runtime it suspends with Keepalive, and the Python
stream wrapper sends the route's ping whenever that wait outlasts the
interval. The Anthropic Messages SSE codec that assembles and replays a
message lives next to the existing SSE helpers, and the Messages binding
exposes it

HandlerBody answers the policy from the shim, which applies the
handler's own server-fulfilled tool rule, and synthesizes when the
pre-request fan-out turned the stream off. A held-back response that
still carries a server-fulfilled tool call nobody fulfilled is raised
instead of leaked. Live streams run no response-stage body hooks: Python
appends the loop's answer as a second message on the same stream, which
no SSE client can consume, so that mode is not ported

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-11 19:14:50 -07:00
..
chat_completions refactor(python-bridge): take NativeCall directly and fold routes into per-route folders (#45413) 2026-10-08 13:48:28 -07:00
host feat(rust): run body hooks on native streams 2026-10-11 19:14:50 -07:00
messages refactor(rust_bridge): route Python state reads through host modules (#45689) 2026-10-11 14:10:16 -07:00
ocr refactor(rust_bridge): route Python state reads through host modules (#45689) 2026-10-11 14:10:16 -07:00
responses refactor(python-bridge): take NativeCall directly and fold routes into per-route folders (#45413) 2026-10-08 13:48:28 -07:00
trace refactor(lens): connect LiteLLM to the independent Lens service (#45529) 2026-10-09 16:17:05 -07:00
__init__.py test: migrate phase 15 legacy tests to tests/unit 2026-09-20 11:55:43 +00:00
AGENTS.md refactor(rust-bridge): unify native call inputs and Messages settings (#45126) 2026-10-07 15:05:43 -07:00
native_route_wheel_test.py refactor(python-bridge): ship a signature base and read the resolved call (#45450) 2026-10-08 17:20:29 -07:00
stubtest.ini test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_bindings.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_catalog.py feat(rust): add the DeepSeek Anthropic Messages config (#45614) 2026-10-09 16:29:46 -07:00
test_clickhouse.py refactor(lens): connect LiteLLM to the independent Lens service (#45529) 2026-10-09 16:17:05 -07:00
test_configuration.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_dispatch.py refactor(rust_bridge): remove rule-gated native secret-manager selection (#44906) 2026-10-06 19:14:55 +00:00
test_failures.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_fork_guard.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_lifecycle.py feat(rust): run body hooks on native streams 2026-10-11 19:14:50 -07:00
test_logger.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
test_preflight.py refactor(rust): move credential inheritance and the SDK limits out of the legacy callback crate into a driver preflight (#43259) 2026-09-26 01:09:36 +00:00
test_public_call.py refactor(python-bridge): ship a signature base and read the resolved call (#45450) 2026-10-08 17:20:29 -07:00
test_runtime.py refactor(rust_bridge): remove native declines so the catalog owns known gaps 2026-10-11 16:36:54 -07:00
test_token_counter.py refactor(rust_bridge): remove native declines so the catalog owns known gaps 2026-10-11 16:36:54 -07:00
test_tokenizer.py refactor(sdk): separate core AWS and tokenizer dependencies (#44447) 2026-10-08 19:07:57 -07:00
test_verify_linux_native_wheel.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00