feat(providers): ride the SSE wire for LiteLLM generate() - #1519
Conversation
✅ Single Commit Policy - COMPLIANTStatus: Policy requirements met • 1 commit • Valid format • Ready for merge 📊 View validation details📝 Commit Details
✅ Validation Results
🤖 Automated validation by NeuroLink Single Commit Enforcement |
14adf05 to
d5ecd27
Compare
|
Warning Review limit reachedNext included review available in 52 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughLiteLLM generation now uses SSE by default. The base provider aggregates streamed responses into the existing result shape, resets idle timeouts per chunk, preserves stream metadata, and retries with JSON when streaming is rejected. ChangesLiteLLM SSE generation
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to The change adds an opt-in SSE transport for LiteLLM while preserving the existing response contract and leaving other providers on the JSON wire; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 AI Review & Build Compliance ✅Status: AI analysis complete • Build rules validated • Ready for review 📊 View detailed analysis results🛡️ Analysis Complete
📋 Ready for Merge When
🤖 AI analysis complete - check individual code comments for specific feedback |
|
Starting review of PR #1519. Analyzing changes file by file following Yama methodology. |
A non-streaming completion sends no bytes until it is fully done, so a proxy/tunnel idle limit (Cloudflare 524 at ~100s) kills any slow model behind a LiteLLM gateway. doGenerate can now opt into stream:true on the wire and aggregate the SSE into the same complete result — schema coercion, tool calls, finish reason and usage unchanged for callers. The request timeout re-arms per chunk (idle semantics), and a backend that rejects streaming gets one retry on the plain JSON wire.
d5ecd27 to
4cb7125
Compare
Documentation Validation Results🚀 Documentation validation passed!
📦 Build artifact uploaded successfully. Ready for deployment preview. Commit: |
🤖 AI Review & Build Compliance ✅Status: AI analysis complete • Build rules validated • Ready for review 📊 View detailed analysis results🛡️ Analysis Complete
📋 Ready for Merge When
🤖 AI analysis complete - check individual code comments for specific feedback |
|
✅ Approved — The PR implements SSE wire support for LiteLLM's non-streaming generate() method, solving the critical problem of tunnel idle timeouts killing slow completions. Summary of ChangesThis PR adds streaming-capable wire transport for LiteLLM's What Changed
Verification Performed
Impact Analysis
Review ScopeReviewed all 12 changed files systematically:
No issues found requiring changes. |
|
🎉 This PR is included in version 11.23.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
A non-streaming completion sends no bytes until it is fully done, so a proxy/tunnel idle limit (e.g. Cloudflare's ~100s 524 on tunneled LiteLLM gateways) kills any slow model — this is what fails the Yama review on qwen3.8-27b (see PR #1514). Callers like Yama cannot switch to
stream()because their schema-bound contract needs the completeGenerateResult(structuredData,toolExecutions,stopReason,usage, JSON damage flags).Fix:
doGeneratein the OpenAI-compat base can now opt intostream: trueon the wire (newuseStreamingWireForGenerate()hook, default false; LiteLLM opts in) and aggregates the SSE via the existingparseSSEStreaminto the exact JSON-wire response shape — everything downstream (content parts, finish-reason mapping, usage clamping, schema coercion) is shared verbatim between the two wires, so callers see zero behavioral change beyond surviving slow completions.createTimeoutControllergainedreset().stream/stream_optionsgets one retry on the plain JSON wire.NEUROLINK_LITELLM_SSE_GENERATE=falserestores the plain JSON wire.Test plan
pnpm run check+check:tools-tests— cleanpnpm run build— cleanpnpm run test:providers-mocked— 58/58, including 4 new contract tests: stream flags on the wire body, multi-chunk aggregation + usage, schema-boundstructuredDatafrom streamed JSON, stream-rejection fallback, and the env escape hatchSummary by CodeRabbit
New Features
NEUROLINK_LITELLM_SSE_GENERATE=falseto restore JSON requests.Bug Fixes
Tests