litellm/litellm-rust
Yujong Lee 80b6ab73b7 refactor(rust): run Python hooks and host calls as async fns on the caller's task
The Python driver was a hand-written continuation machine: every hook and
host call returned a step, the driver parked a resume function in a Pending
slot, and the hook chain kept per-phase state to pick up where it stopped.
This replaces that with one async body per call, polled only from the
caller's Python task through a new PythonTask primitive. Hooks and host
calls are plain async fns that await Python awaitables through
PythonTask::settle, so the caller's task and contextvars context still run
every hook of a call, and the core coroutine stays as it is.

HookStep, HostStep, HookResume, HostResume and the Pending enum are gone.
The hook chain is a loop over boxed async hooks. The legacy callback
adapter awaits its deployment hooks and failure handlers in place, and the
cache binding awaits the Python cache the same way.

The handle shares the binding, hooks and keyword view with the body through
a lock released around native steps and stream boundaries, so GC traversal
still reaches retained Python objects while a call waits on the runtime or
on its consumer. A new driver test pins that an abandoned stream retained
by a hook is collected.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-12 01:02:47 +00:00
..
.agents/skills refactor(rust): derive strum VariantArray and string conversions (#45434) 2026-10-08 21:24:49 +00:00
crates refactor(rust): run Python hooks and host calls as async fns on the caller's task 2026-10-12 01:02:47 +00:00
docs/adrs docs(rust): add ADRs for the Rust core (#45205) 2026-10-08 10:21:56 -07:00
.gitignore feat: add LiteLLM Rust workspace with Mistral OCR bridge (#31033) 2026-06-23 13:16:47 -07:00
AGENTS.md refactor(rust): share provider constants via llms-types and restructure AGENTS.md (#45850) 2026-10-10 16:53:35 -07:00
Cargo.lock refactor(rust): give Messages configs typed litellm params (#45611) 2026-10-09 16:29:45 -07:00
Cargo.toml feat(rust): one LitellmParams type for a config and a caller (#45642) 2026-10-09 16:29:45 -07:00
clippy.toml feat(rust): add the MCP gateway (#43470) 2026-09-27 19:37:41 -07:00