mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-26 22:30:11 +00:00
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> |
||
|---|---|---|
| .. | ||
| benches | ||
| src | ||
| tests | ||
| AGENTS.md | ||
| build.rs | ||
| Cargo.toml | ||
| preflight_contract.json | ||