Skip to content

fix(gateway): onFallback reports the most recent error, as the walkers do - #348

Merged
jddunn merged 1 commit into
masterfrom
fix/gateway-onfallback-latest-error
Oct 12, 2026
Merged

jddunn merged 1 commit into
masterfrom
fix/gateway-onfallback-latest-error

Conversation

@jddunn

@jddunn jddunn commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Fold of the review comments on #346 (CodeRabbit and Codex's GitHub review, the same finding): when a fallback hop could not start on the way to the hop that serves, onFallback received the error the previous hop failed with rather than the most recent one. It now receives the most recent error, as generateText's and streamText's walks report it: a hop that could not start on the way, else the previous hop's failure.

Test: completionGateway.test.ts, a fallback that cannot start between the failed hop and the one that serves.

Summary by Sourcery

Report the latest failure reason through completion fallback callbacks, matching the behavior of the text-generation walkers.

Bug Fixes:

  • Ensure completion fallback callbacks receive the most recent error when an intermediate fallback hop cannot start.

Tests:

  • Add coverage for fallback error reporting when an intermediate provider initialization fails.

…s do

When a fallback hop could not start on the way to the hop that serves, the
error onFallback received was still the one the previous hop failed with.
It is the most recent error, as generateText's and streamText's walks report
it: a hop that could not start on the way, else the previous hop's failure.
@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 12, 2026 15:31
@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Sorry @jddunn, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 days and 14 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 2 billable files and costs up to $0.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 31 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: framerslab/agentos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 3023cd32-ca18-4d67-a1c4-9e5e25c0be87

📥 Commits

Reviewing files that changed from the base of the PR and between de41a67 and f2a5456.


📒 Files selected for processing (2)
  • src/api/runtime/__tests__/completionGateway.test.ts
  • src/api/runtime/completionGateway.ts

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

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T15:32:53.315764Z f2a5456 PR opened
ℹ️ 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.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The gateway now passes the most recent error to onFallback, matching generateText and streamText walker behavior: intermediate hop-start failures take precedence over the previous hop's failure. A regression test covers this multi-hop fallback scenario.

Sequence diagram for gateway fallback error reporting

sequenceDiagram
    participant Gateway
    participant PreviousHop
    participant IntermediateHop
    participant ServingHop
    participant onFallback

    Gateway->>PreviousHop: request
    PreviousHop-->>Gateway: failure
    Gateway->>IntermediateHop: start hop
    IntermediateHop-->>Gateway: start failure
    Gateway->>ServingHop: request
    ServingHop-->>Gateway: resolution
    Gateway->>onFallback: onFallback({from, to, hop, error: start failure})
Loading

File-Level Changes

Change Details Files
Report the most recent failure when notifying fallback transitions.
  • Prioritize an error from an intermediate hop that could not start over the prior hop's failure.
  • Retain the prior failure and generic fallback error as subsequent fallbacks.
  • Update the callback comment to document alignment with walker error reporting.
src/api/runtime/completionGateway.ts
Add regression coverage for error selection across an unstartable intermediate hop.
  • Configure the intermediate Anthropic hop to fail initialization.
  • Verify onFallback targets the serving OpenRouter hop and reports its invalid-key error.
src/api/runtime/__tests__/completionGateway.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@jddunn
jddunn merged commit c1b4847 into master Oct 12, 2026
9 checks passed
@jddunn
jddunn deleted the fix/gateway-onfallback-latest-error branch October 12, 2026 15:35
github-actions Bot pushed a commit that referenced this pull request Oct 12, 2026
## [0.13.69](v0.13.68...v0.13.69) (2026-10-12)

### fix

* **gateway:** onFallback reports the most recent error, as the walkers do (#348) ([c1b4847](c1b4847))
* **gemini:** read data URLs in linear time, send https images for Gemini to fetch, and read every block as a content filter (#342) ([ad4df66](ad4df66))
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