litellm/litellm-rust/crates/llms/src
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
..
anthropic refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
aws_textract refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
azure_ai refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
base_llm feat(rust): run body hooks on native streams 2026-10-11 19:14:50 -07:00
bedrock feat(rust): add native Bedrock Claude Platform and Mantle Messages (#45908) 2026-10-11 15:55:47 -07:00
bedrock_mantle feat(rust): add native Bedrock Claude Platform and Mantle Messages (#45908) 2026-10-11 15:55:47 -07:00
cohere refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
deepseek refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
minimax feat(rust): support MiniMax Messages API (#45896) 2026-10-11 15:12:48 -07:00
mistral refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
openai refactor(rust_bridge): one Python parameter list per route and Python cache on every inference route 2026-10-11 17:08:55 -07:00
openai_like refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
openrouter feat(rust): add native OpenRouter Messages (#45910) 2026-10-11 15:48:50 -07:00
reducto refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
tencent feat(rust): support Tencent Messages API (#45899) 2026-10-11 22:40:20 +00:00
vertex_ai refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
error.rs refactor(rust): share anthropic types, request helpers, and streaming contracts across crates (#43426) 2026-09-27 14:53:12 -07:00
lib.rs feat(rust): add native Bedrock Claude Platform and Mantle Messages (#45908) 2026-10-11 15:55:47 -07:00