Skip to content

harness(openai): stream() JSON fallback when upstream ignores stream:true#56

Merged
senamakel merged 1 commit into
mainfrom
harness/openai-stream-json-fallback
Jul 11, 2026
Merged

harness(openai): stream() JSON fallback when upstream ignores stream:true#56
senamakel merged 1 commit into
mainfrom
harness/openai-stream-json-fallback

Conversation

@senamakel

Copy link
Copy Markdown
Member

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

…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
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c49507ba-ebb7-4e74-a46c-ab0b558b09e1

📥 Commits

Reviewing files that changed from the base of the PR and between 40cd29b and 014b345.

📒 Files selected for processing (1)
  • src/harness/providers/openai/transport.rs

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@senamakel senamakel merged commit 4840b3a into main Jul 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant