harness(openai): stream() JSON fallback when upstream ignores stream:true#56
Conversation
…ream:true Some OpenAI-compatible endpoints (and many test mocks) ignore stream:true and return a single non-streaming JSON body instead of an SSE event stream. The strict SSE parser then yields no items and a streaming turn stalls. stream() now checks the response content-type: when it is not text/event-stream, it reads the JSON body, parses it as one completion (applying prompt-guided tool recovery), and surfaces it as Started + one MessageDelta + Completed — matching the tolerant behaviour of hand-rolled clients so a non-streaming upstream still drives a streaming turn. Unblocks OpenHuman's crate-native turn cutover against its JSON-only e2e mocks (issue #4249 Phase 3). fmt + clippy clean. Claude-Session: https://claude.ai/code/session_01U8NDGbt9tKj443VquzycLB
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 2 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 014b345a8d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .and_then(|v| v.to_str().ok()) | ||
| .map(|ct| ct.to_ascii_lowercase().contains("text/event-stream")) | ||
| .unwrap_or(false); | ||
| if !is_event_stream { |
There was a problem hiding this comment.
Keep parsing SSE when headers are missing
When an OpenAI-compatible server or proxy streams valid data: events but omits or mislabels Content-Type, this new if !is_event_stream path consumes the whole body with response.text() and passes the SSE payload to parse_response, which fails because it is not a chat-completion JSON object. The previous code parsed the SSE body regardless of headers, so these endpoints regress from working streaming to a serialization error; consider sniffing the body or falling back to JSON only after confirming it is not SSE.
Useful? React with 👍 / 👎.
Lenient streaming: parse a non-SSE JSON body as one completion (Started + MessageDelta + Completed). Unblocks OpenHuman's crate-native turn cutover against JSON-only e2e mocks (#4249). fmt+clippy clean.
https://claude.ai/code/session_01U8NDGbt9tKj443VquzycLB