litellm/litellm-rust/crates/host-python/src
yujonglee 8302f006dd
refactor(rust-bridge): return an unstarted Execution from native entrypoints and drive it in Python (#46299)
* refactor(rust-bridge): return an unstarted Execution from native entrypoints and drive it in Python

Rust's run_call built Python streams itself and imported
litellm.rust_bridge.streams by name, so sync calls were driven in Rust
while async calls came back as a Rust-made coroutine. Every native
inference entrypoint now returns one unstarted Execution and
public_execution.py drives it with lifecycle.run or lifecycle.drive,
wrapping streams and _hidden_params on the Python side. Rust only
imports the lifecycle step classes through StepTypes, and
python-bridge/src/lifecycle.rs, PythonLifecycle and streams.py are gone.

The adapter trusts the _native.pyi contract with a single cast instead
of a per-request runtime_checkable isinstance. Binding tests assert the
adapter starts the execution and returns its completed value rather
than checking callable identity.

* refactor(rust-bridge): fold lifecycle and public_execution into one execution module

The public stream wrappers only forwarded to the lifecycle streams and added the
header dict, so the streams now carry _hidden_params themselves. lifecycle.py no
longer held any call lifecycle, just the Execution driver, so it is renamed to
execution.py and absorbs the synchronous and asynchronous adapters

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

* fix(rust-bridge): keep execution.py free of third-party imports

The host-python tests load execution.py into a bare interpreter, so the
pydantic header validation broke them. The stream head comes from the
binding's encode_stream_head, which always builds a str-keyed dict

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

* test(host-python): preserve pre-async hook coverage after execution handoff

* style(rust-bridge): sort litellm_host_python imports

Co-Authored-By: Yujong Lee <yujong@berri.ai>

* test(rust-bridge): drive unstarted native calls through execution in the split lifecycle tests

Co-Authored-By: Yujong Lee <yujong@berri.ai>

* fix(rust-bridge): mark execution TypeVar as Final

Co-Authored-By: Yujong Lee <yujong@berri.ai>

* test(rust-bridge): cover stream close, read failure, and sync suspension in execution

Co-Authored-By: Yujong Lee <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-14 17:50:44 -07:00
..
hooks/chain refactor(host-python): collect host failures in a thiserror Error enum (#46361) 2026-10-14 17:19:06 -07:00
argument.rs refactor(python-bridge): ship a signature base and read the resolved call (#45450) 2026-10-08 17:20:29 -07:00
binding.rs refactor(rust): share call lifecycle across route-owned inference (#43461) 2026-09-27 16:05:30 -07:00
caller.rs refactor(rust-bridge): generator-style execution protocol with stream step names (#46282) 2026-10-14 17:19:07 -07:00
conversion_cache.rs feat: improve trace ingestion and trace details (#43975) 2026-10-01 13:45:33 -07:00
driver.rs refactor(rust-bridge): return an unstarted Execution from native entrypoints and drive it in Python (#46299) 2026-10-14 17:50:44 -07:00
error.rs refactor(rust-bridge): return an unstarted Execution from native entrypoints and drive it in Python (#46299) 2026-10-14 17:50:44 -07:00
file_reader.rs refactor(host-python): collect host failures in a thiserror Error enum (#46361) 2026-10-14 17:19:06 -07:00
fork_gate.rs refactor(rust): drop a comment that repeats the reserve doc 2026-09-19 18:22:06 +00:00
gil.rs refactor(host-python): collect host failures in a thiserror Error enum (#46361) 2026-10-14 17:19:06 -07:00
handle.rs refactor(rust-bridge): return an unstarted Execution from native entrypoints and drive it in Python (#46299) 2026-10-14 17:50:44 -07:00
hooks.rs refactor(rust): centralize host execution and compose callbacks (#43515) 2026-09-28 19:20:27 +00:00
lib.rs refactor(rust-bridge): return an unstarted Execution from native entrypoints and drive it in Python (#46299) 2026-10-14 17:50:44 -07:00
marshal.rs refactor(rust-bridge): share field and response marshaling (#45187) 2026-10-07 17:22:23 -07:00
native.rs refactor(host-python): collect host failures in a thiserror Error enum (#46361) 2026-10-14 17:19:06 -07:00
owned.rs refactor(rust): share call lifecycle across route-owned inference (#43461) 2026-09-27 16:05:30 -07:00
runtime.rs refactor(host-python): collect host failures in a thiserror Error enum (#46361) 2026-10-14 17:19:06 -07:00
services.rs feat(cache): select Rust caching through explicit cache objects (#43601) 2026-09-29 00:01:44 +00:00