Repository navigation
refactor(native): separate request data from execution context - #39766
yujonglee-berri merged 0 commit into
Conversation
Greptile SummaryThis PR centralizes native-versus-Python selection behind typed endpoint dispatch contracts and makes fallback conservative after native work may have begun.
Confidence Score: 5/5The PR appears safe to merge because no new actionable failure remains and the packaged readiness registry prevents incomplete native routes from becoming active. The centralized dispatch consistently falls back only before native commitment, while upstream and unknown native failures remain terminal to prevent duplicate provider operations. Lazy request preparation and explicit readiness metadata preserve existing Python behavior for optional surfaces. The previous OCR finding was manually resolved and the current implementation permits explicit native declines to return to Python.
|
| Filename | Overview |
|---|---|
| litellm/rust_bridge/runtime.py | Defines the shared sync, async, and required-native dispatch policy, including conservative exception classification. |
| litellm/rust_bridge/bindings.py | Resolves typed native callables only when readiness metadata declares the corresponding route. |
| litellm/rust_bridge/chat_completions.py | Routes eligible non-streaming Anthropic and Bedrock chat requests through the centralized dispatch contract. |
| litellm/main.py | Moves the complete Python provider switch behind a single chat-completion fallback selected by EndpointDispatch. |
| litellm/rust_bridge/messages.py | Adds centralized sync and async Messages dispatch with lazy request construction and safe-decline fallback. |
| litellm/ocr/main.py | Integrates OCR with readiness-gated lazy native preparation while preserving Python fallback. |
| litellm/responses/main.py | Adds one-shot Responses HTTP dispatch while retaining Python handling for streams, custom clients, and unavailable native routes. |
| litellm/rust_bridge/responses_websocket.py | Wraps native Responses WebSocket sessions in the shared readiness and fallback policy. |
| litellm/rust_bridge/transcription.py | Expresses transcription as an intentionally required-native endpoint with explicit unavailable errors. |
| litellm-rust/crates/python-bridge/src/errors.rs | Treats connection and other ambiguous post-selection failures as terminal upstream errors rather than fallback signals. |
| litellm-rust/crates/python-bridge/src/lib.rs | Publishes an empty packaged readiness registry so incomplete native stubs remain inactive. |
Reviews (2): Last reviewed commit: "fix(python): avoid runtime generic const..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
8ccf341 to
8bd2ae1
Compare
54dcd5c to
1d78c5b
Compare
8da62aa to
60d1ed4
Compare
|
@greptile-apps review |
f14cfa6 to
c2edf29
Compare
d259f5e to
8af1d51
Compare
a2ed1e1 to
d03b9a1
Compare
d03b9a1 to
0f886a6
Compare
|
The request/context layer is restored for review in #39941 after GitHub automatically marked this PR merged during branch reordering |
TLDR
Problem this solves:
How it solves it:
User Flow
Before: developers use the existing endpoint request and response formats
After: the same requests retain their existing formats
Implementation
Separates provider request data from execution context. Dispatch plumbing is reviewed in #39913, error/fallback fixes in #39923, and endpoint-adapter migration in #39914
All seven Python contracts use
native(request, *, context). Route dataclasses contain provider inputs and shared connection options. LiteLLM metadata, forwarding configuration, call identity, and attribution live in execution context. Responses API metadata remains provider dataPyO3 extracts dataclass attributes into bridge-local types and converts them into Python-independent Rust types. Core and gateway entrypoints receive request data and execution context separately. Tests cover field ownership, provider payloads, lifecycle identity, and malformed boundary inputs
Typed native selectors, callable inference, and exception-class validation remain shared with #39913. Rust enablement remains process-wide as established in #39928. Type-contract and configuration tests persist through every later layer
Validation: 146 focused Python tests pass. Local make check passes. Rust source is unchanged by this restack; previous Rust validation was not rerun
Relevant issues
Stack order: #39928, #39913, #39923, #39914, #39766, then #39484 for callback/readiness work
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
No live provider proof is claimed. This refactor preserves public endpoint schemas
Type
Refactoring
Test
Caveats (if any)
Medium
Final Attestation