Skip to content

Retry transient model route misses in console chat - #1277

Merged
i386 merged 2 commits into
mainfrom
agent/console-model-route-retry
Aug 13, 2026
Merged

Retry transient model route misses in console chat#1277
i386 merged 2 commits into
mainfrom
agent/console-model-route-retry

Conversation

@i386

@i386 i386 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • retry one transient model-route 404 in console chat
  • keep the selected model and request body unchanged while public gossip/routing converges
  • add coverage for recovery from an apple/system model-not-found response

Why

The console can receive a model from /api/models before the public gateway has an eligible route for it. The first /api/responses request then returns 404 even though the model is valid and becomes routable moments later. Previously this surfaced as “Message failed to send” and required a manual refresh or model re-selection.

The adapter now waits 500 ms and retries once only for a 404 whose error body identifies a missing model. Other errors are still surfaced immediately, and aborts cancel the retry wait.

Validation

  • just build passes.
  • Added a focused adapter test covering the transient 404 and successful streamed retry.
  • Full UI suite: the new test passes; one unrelated pre-existing DataModeContext localStorage test remains failing in this checkout.

Fixes the console-side portion of the public model catalog/routing convergence issue.

Summary by CodeRabbit

  • Bug Fixes
    • Chat requests now automatically retry once after a brief delay when the selected model is temporarily unavailable.
    • Successful retries continue streaming responses normally without requiring user action.
    • Requests canceled during the retry stop cleanly.
    • Existing error handling is preserved when the model cannot be recovered or the retry conditions are not met.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a3c1e45-f577-45d7-925d-8fc05a8adf48

📥 Commits

Reviewing files that changed from the base of the PR and between 55b9c3a and af3e542.

📒 Files selected for processing (2)
  • crates/mesh-llm-ui/src/features/chat/api/mesh-connection.test.ts
  • crates/mesh-llm-ui/src/features/chat/api/mesh-connection.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/mesh-llm-ui/src/features/chat/api/mesh-connection.test.ts
  • crates/mesh-llm-ui/src/features/chat/api/mesh-connection.ts

📝 Walkthrough

Walkthrough

The chat connection detects qualifying HTTP 404 model-route errors, waits 500 ms with abort support, and retries once. Tests verify recovery through a streamed response.

Changes

Model-route retry

Layer / File(s) Summary
Cancellable retry flow and recovery test
crates/mesh-llm-ui/src/features/chat/api/mesh-connection.ts, crates/mesh-llm-ui/src/features/chat/api/mesh-connection.test.ts
The connection detects missing-model-route 404 responses, waits 500 ms, retries once, and preserves abort and API error handling. The test verifies two fetch attempts and recovered streamed text output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to af3e5

The change narrowly retries one transient missing-model response while preserving the request and selected model; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant MeshConnection
  participant Fetch
  participant RetryDelay
  participant StreamResponse

  MeshConnection->>Fetch: Request model stream
  Fetch-->>MeshConnection: 404 missing model route
  MeshConnection->>RetryDelay: Wait 500 ms or abort
  RetryDelay-->>MeshConnection: Delay completes
  MeshConnection->>Fetch: Retry request once
  Fetch-->>StreamResponse: Return successful stream
  StreamResponse-->>MeshConnection: Emit text content
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the one-time retry for transient model-route 404 errors in console chat.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/console-model-route-retry

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/mesh-llm-ui/src/features/chat/api/mesh-connection.test.ts (1)

450-478: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the recovery test deterministic and verify the recovered text.

This test waits for the real 500 ms retry delay. Use Vitest fake timers and advance them after the retry wait starts.

The current assertion only proves that a text event exists. Assert that the emitted text contains "Recovered" so an empty or incorrect recovered delta fails.

As per coding guidelines, “Keep tests deterministic; avoid relying on real timers unless using fake timers.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/mesh-llm-ui/src/features/chat/api/mesh-connection.test.ts` around
lines 450 - 478, Update the recovery test around createMeshConnectionAdapter to
use Vitest fake timers, advancing the clock after the retry delay begins so it
does not wait on the real 500 ms delay. Strengthen the chunks assertion to
verify the emitted text content includes “Recovered,” not merely that a text
event exists, and restore fake timers after the test.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/mesh-llm-ui/src/features/chat/api/mesh-connection.ts`:
- Around line 223-227: Update the retry handling around waitForModelRouteRetry
so that when abortSignal.aborted becomes true during the wait, the function
returns immediately before constructing ApiError. Preserve the existing ApiError
path for non-aborted failures and non-retryable responses.

---

Nitpick comments:
In `@crates/mesh-llm-ui/src/features/chat/api/mesh-connection.test.ts`:
- Around line 450-478: Update the recovery test around
createMeshConnectionAdapter to use Vitest fake timers, advancing the clock after
the retry delay begins so it does not wait on the real 500 ms delay. Strengthen
the chunks assertion to verify the emitted text content includes “Recovered,”
not merely that a text event exists, and restore fake timers after the test.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 75d30edd-3e28-402d-9ab5-c1b531d7be47

📥 Commits

Reviewing files that changed from the base of the PR and between 3fb86fe and 55b9c3a.

📒 Files selected for processing (2)
  • crates/mesh-llm-ui/src/features/chat/api/mesh-connection.test.ts
  • crates/mesh-llm-ui/src/features/chat/api/mesh-connection.ts

Comment thread crates/mesh-llm-ui/src/features/chat/api/mesh-connection.ts
@i386
i386 merged commit 767edfb into main Aug 13, 2026
3 checks passed
@i386
i386 deleted the agent/console-model-route-retry branch August 13, 2026 02:16
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.

2 participants