5. Circuit breaker + OpenRouter fallback #6

Open
opened 2026-06-15 02:48:58 +03:00 by doru · 0 comments
Owner

Parent

  • #1 Epic: Model Switching via Sidecar

What to build

When the Sidecar is unreachable or llama-server fails to recover, the Router uses a circuit breaker pattern and falls back to OpenRouter (DeepSeek V4 Flash). Removes the old x-intelligence-level: High header routing — OpenRouter is now purely a fallback, not a direct routing rule.

  • Router — circuit breaker tracks Sidecar failures in memory. On Sidecar failure, attempts to recover llama-server via Sidecar up to 3 times. After 3 failed attempts, circuit opens → routes to OpenRouter. Circuit resets on successful Sidecar interaction.
  • Router — removes x-intelligence-level: High header logic entirely. Adds OpenRouter as fallback backend with OPENROUTER_API_KEY from .env.

Acceptance criteria

  • Circuit breaker tracks Sidecar failures (in-memory counter)
  • Up to 3 auto-recovery attempts via Sidecar before opening circuit
  • Open circuit → routes request to OpenRouter (DeepSeek V4 Flash)
  • Successful Sidecar interaction resets circuit breaker
  • Old x-intelligence-level: High header routing removed
  • OPENROUTER_API_KEY read from environment
  • Tests: Sidecar down triggers circuit breaker, fallback to OpenRouter, circuit reset on recovery

Blocked by

  • #4 (Automatic model detection and switch)

User stories covered

7

## Parent - #1 Epic: Model Switching via Sidecar ## What to build When the Sidecar is unreachable or llama-server fails to recover, the Router uses a circuit breaker pattern and falls back to OpenRouter (DeepSeek V4 Flash). Removes the old `x-intelligence-level: High` header routing — OpenRouter is now purely a fallback, not a direct routing rule. - **Router** — circuit breaker tracks Sidecar failures in memory. On Sidecar failure, attempts to recover llama-server via Sidecar up to 3 times. After 3 failed attempts, circuit opens → routes to OpenRouter. Circuit resets on successful Sidecar interaction. - **Router** — removes `x-intelligence-level: High` header logic entirely. Adds OpenRouter as fallback backend with `OPENROUTER_API_KEY` from `.env`. ## Acceptance criteria - [ ] Circuit breaker tracks Sidecar failures (in-memory counter) - [ ] Up to 3 auto-recovery attempts via Sidecar before opening circuit - [ ] Open circuit → routes request to OpenRouter (DeepSeek V4 Flash) - [ ] Successful Sidecar interaction resets circuit breaker - [ ] Old `x-intelligence-level: High` header routing removed - [ ] `OPENROUTER_API_KEY` read from environment - [ ] Tests: Sidecar down triggers circuit breaker, fallback to OpenRouter, circuit reset on recovery ## Blocked by - #4 (Automatic model detection and switch) ## User stories covered 7
doru added the
type:afk
triage:ready
labels 2026-06-15 02:48:58 +03:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: doru/intelligence-router#6
No description provided.