Skip to content

fix(route-proxy): fail over on pre-content stream errors (#3325) - #5558

Merged
dezren39 merged 5 commits into
mainfrom
queue/8932-3325-route-stream-fallback
Nov 10, 2026
Merged

dezren39 merged 5 commits into
mainfrom
queue/8932-3325-route-stream-fallback

Conversation

@dezren39

@dezren39 dezren39 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

2xx streaming leg
  buffer first content (250 ms / 64 KiB bound)
  pre-content SSE/transport failure -> record + walk to next candidate
  post-content failure -> record only; never splice responses

In-stream quota errors retain RateLimit classification and Retry-After detail in route_attempt.

Fixes #3325.

Evidence

  • Before: the new regression failed; the client received the first leg's quota-error event.
  • After: node --test bin/opencode-route-proxy.test.mjs — 39/39 pass, including fragmented SSE errors, pre-content transport breaks, delayed first content, and no post-content retry.
  • node --check bin/opencode-route-proxy.mjs and git diff --check pass.

Merge Danger

Door: two-way

Blast Radius: route-proxy

Buffering is limited to the pre-content window; mid-stream failover remains disabled.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 4, 2026 15:28
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T21:52:27.868964Z e341314 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: f9beae3979

ℹ️ 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".

Comment thread bin/opencode-route-proxy.mjs Resolved
Comment thread bin/opencode-route-proxy.mjs Resolved
@dezren39

dezren39 commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

agent-note:v1
task: 14021
lane: code-b
state: handed_off
summary: Claimed by lane code-b 2026-11-09T01:22Z; execution lane assignment is opencode (lane row 5305). PR #5558 verified OPEN fresh, not draft, no labels (no hard-stop), head f9beae3 on branch queue/8932-3325-route-stream-fallback; only check is CodeRabbit skipping. Handing off to the opencode claimant per runbook 1b; parked 1200s.
next: opencode claimant launches bound session for task 14021 and shepherds PR #5558 (batch #7297 part 5) to merge or a reasoned close.

@dezren39 dezren39 added work/assigned Queue worker lifecycle state queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition queue/claimed Queue worker lifecycle state status/in-progress Queue worker lifecycle state and removed status/parked Deliberately paused with a recorded resume condition queue/parked Queue task is parked (waiting on CI, time, or an event) status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state labels Nov 9, 2026
@dezren39

Copy link
Copy Markdown
Member Author

🤖 Agent note · merging under the standing criteria (task 14021, lane code-t)

  • Both Codex P2 findings fixed and their threads resolved: 64a92f7 (parse complete events before trimming + data-aware buffer bound; cancel the rejected upstream on preface overflow) and e341314 (relay defers the preface limit while a data event is in progress — the prepare-window/relay phase-boundary case the new regression test exposed under load), each with regression tests and thread replies carrying the evidence.
  • Branch merged with current main (fdff505; two trivial test-file conflicts resolved as unions); net diff vs main is only bin/opencode-route-proxy.mjs + its test file.
  • Tests at head e341314: node --test bin/opencode-route-proxy.test.mjs — 44 pass, 0 fail, run twice.
  • CI: only CodeRabbit (NEUTRAL) is attached to this PR; merging under the standing merge authority (CI runs on main).

@dezren39
dezren39 merged commit 3fc163e into main Nov 10, 2026
0 of 10 checks passed
@dezren39
dezren39 deleted the queue/8932-3325-route-stream-fallback branch November 10, 2026 21:49
@dezren39 dezren39 removed the status/parked Deliberately paused with a recorded resume condition label Nov 10, 2026
@dezren39 dezren39 removed queue/parked Queue task is parked (waiting on CI, time, or an event) work/assigned Queue worker lifecycle state labels Nov 10, 2026

@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: e341314275

ℹ️ 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".

Comment on lines +1065 to +1069
if (state.done)
return {
error: new LeafError("leaf stream ended before content", {
tag: "ProviderInternal",
}),

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 Preserve successful terminal chunks with no content

When a provider returns a valid empty completion—an assistant role followed by delta: {} with finish_reason: "stop", "content_filter", or "length", then [DONE]—the inspector never sets contentStarted because it ignores finish_reason. This branch consequently discards the completed response and retries another provider; if all candidates return empty completions, the client receives a proxy error instead of the original terminal chunks and usage. Previously these events were relayed unchanged. Track terminal completion separately from nonempty content so an explicitly finished empty response is not treated as a failed stream.

Useful? React with 👍 / 👎.

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.

workhorse route: sessions die on quota-exhausted muse-spark leg instead of falling through to a live leg (22:40 wave, 5 roots)

1 participant