

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# src/hooks/runtime-fallback/ (Reactive Provider Error Recovery)23**Generated:** 2026-07-17 (7d664b96b)45## OVERVIEW6729 source files (~2530 LOC). Session Tier hook that **reactively** switches to fallback models when API providers return errors at runtime (429, 503, quota exhausted, cooldown signals). Distinct from `model-fallback` (which applies preemptively at chat.params).89## RUNTIME-FALLBACK vs MODEL-FALLBACK1011| Aspect | runtime-fallback | model-fallback |12|--------|-----------------|----------------|13| **Trigger** | Reactive (after error occurs) | Proactive (at request time) |14| **Event** | session.error, message.updated, session.status | chat.params |15| **Config source** | `categories[].fallback_models`, `agents[].fallback_models` | `AGENT_MODEL_REQUIREMENTS` hardcoded chains |16| **State** | Per-session FallbackState + cooldown tracking | Module-global pendingModelFallbacks |17| **Use case** | Provider errors during execution | Pre-configured agent fallback chains |1819They operate **independently**; no direct integration.2021## ERROR DETECTION2223### HTTP Status Codes (configurable)24Default retry codes: `429, 500, 502, 503, 504`2526### Error Message Patterns (constants.ts)27```28/rate.?limit/i, /too.?many.?requests/i, /quota.*reset.*after/i,29/exhausted.*capacity/i, /all.*credentials.*for.*model/i,30/cool(?:ing)?.?down/i, /model.*not.*supported/i,31/service.?unavailable/i, /overloaded/i, /temporarily.?unavailable/i32```3334### Error Type Classification (error-classifier.ts)35- `missing_api_key`: provider rejects auth36- `model_not_found`: model unavailable37- `quota_exceeded`: billing/quota hit38- Auto-retry signal detection via `auto-retry-signal.ts`: extracts "retrying in ~2 weeks" style signals, triggers immediate fallback3940## FALLBACK STATE MACHINE4142```typescript43interface FallbackState {44 originalModel: string45 currentModel: string46 fallbackIndex: number47 failedModels: Map<string, number> // model → cooldown-until timestamp48 attemptCount: number49 pendingFallbackModel?: string50}51```5253## FALLBACK CHAIN RESOLUTION (fallback-models.ts)5455Priority order (`getRawFallbackModelsForSession`):561. **Session category** `fallback_models` (via SessionCategoryRegistry)572. **Agent config** `fallback_models`, then the agent's own category `fallback_models` (`tryGetFallbackFromAgent`)583. **Session ID pattern match** (detect agent from session ID, then step 2 logic)5960When the resolved agent is `plan` and `sisyphus_agent` is enabled (`disabled !== true`, `planner_enabled !== false`, `replace_plan !== false`), it inherits `prometheus`'s fallback models after steps 2 and 3. Explicit `plan` `fallback_models` (even `[]`) takes precedence and suppresses inheritance.6162## RETRY FLOW6364```65session.error / message.updated (with error) / session.status (retry signal)66 → isRetryableError(error)?67 → getFallbackModelsForSession(sessionID, agent)68 → findNextAvailableFallback(): skip cooldown models69 → prepareFallback(): update state, mark current failed70 → dispatchFallbackRetry(): toast notification + promptAsync with new model71 → 30s timeout: abort and try next if exceeded72```7374## COOLDOWN MECHANISM7576Failed models enter 60s cooldown. `findNextAvailableFallback()` skips models in cooldown, preventing thrashing on persistently failing models.7778## KEY FILES7980| File | Purpose |81|------|---------|82| `hook.ts` | `createRuntimeFallbackHook()`: composes all handlers |83| `event-handler.ts` | Route session lifecycle (created, error, stop, idle) |84| `message-update-handler.ts` | Handle error parts in `message.updated` |85| `session-status-handler.ts` | Handle provider retry signals in session.status |86| `chat-message-handler.ts` | Apply fallback model override on chat.message |87| `error-classifier.ts` | `isRetryableError()`, `classifyErrorType()` |88| `auto-retry-signal.ts` | Extract "retrying in..." signals |89| `fallback-state.ts` | State machine: createFallbackState, prepareFallback, findNextAvailableFallback, isModelInCooldown |90| `fallback-models.ts` | Resolve chain from config hierarchy (strings + raw objects) |91| `fallback-bootstrap-model.ts` | Derive initial model when state missing |92| `fallback-retry-dispatcher.ts` | Toast + dispatch retry orchestration |93| `auto-retry.ts` | Abort, timeout scheduling, cleanup |94| `agent-resolver.ts` | Session → agent name normalization |95| `retry-model-payload.ts` | Build model payload (providerID/modelID/variant/reasoningEffort) |96| `visible-assistant-response.ts` | Detect if assistant produced real output vs just errors |97| `last-user-retry-parts.ts` | Extract last user message parts for retry |9899## NOTES100101- Cooldown and failure tracking are **per-session**; concurrent sessions don't share state102- `visible-assistant-response.ts` prevents retry if the assistant already produced a partial valid response103- Runtime-fallback is registered in the Session Tier via `create-session-hooks.ts`104
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| code-yeongyu/oh-my-openagentpackages/omo-opencode/src/tools/look-at/AGENTS.md · 68k | AGENTS.md | arch | 68/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentassets/AGENTS.md · 68k | AGENTS.md | buildteststylearch | 88/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/AGENTS.md · 68k | AGENTS.md | buildtestlint-formatstyle+3 | 83/100 | today | |
| code-yeongyu/oh-my-openagentpackages/omo-codex/plugin/components/ultrawork/AGENTS.md · 68k | AGENTS.md | buildteststylearch+1 | 77/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/omo-opencode/src/tools/background-task/AGENTS.md · 68k | AGENTS.md | arch | 70/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/omo-opencode/src/agents/sisyphus/AGENTS.md · 68k | AGENTS.md | arch | 56/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/omo-opencode/src/hooks/ralph-loop/AGENTS.md · 68k | AGENTS.md | arch | 62/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/omo-opencode/src/hooks/rules-injector/AGENTS.md · 68k | AGENTS.md | archdo-not | 69/100 | 13 days ago | |
| code-yeongyu/oh-my-openagent.agents/AGENTS.md · 68k | AGENTS.md | stylearchtesting-strategydatabase | 64/100 | 13 days ago | |
| code-yeongyu/oh-my-openagent.opencode/AGENTS.md · 68k | AGENTS.md | stylearchdo-not | 71/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentAGENTS.md · 68k | AGENTS.md | setupbuildtestlint-format+11 | 84/100 | today | |
| code-yeongyu/oh-my-openagentpackages/agents-md-core/AGENTS.md · 68k | AGENTS.md | archdependenciesapi | 48/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/ast-grep-mcp/AGENTS.md · 68k | AGENTS.md | buildstylearchdependencies+1 | 78/100 | 7 days ago | |
| code-yeongyu/oh-my-openagentpackages/boulder-state/AGENTS.md · 68k | AGENTS.md | archapi | 48/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/claude-code-compat-core/AGENTS.md · 68k | AGENTS.md | archagent-behaviour | 56/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/comment-checker-core/AGENTS.md · 68k | AGENTS.md | archdependenciesapi | 48/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/delegate-core/AGENTS.md · 68k | AGENTS.md | stylearchdependenciesapi | 60/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/git-bash-mcp/AGENTS.md · 68k | AGENTS.md | buildtestlint-formatarch+1 | 82/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/hashline-core/AGENTS.md · 68k | AGENTS.md | archtypesdependenciesapi | 48/100 | 13 days ago | |
| code-yeongyu/oh-my-openagentpackages/lsp-daemon/AGENTS.md · 68k | AGENTS.md | buildtestlint-formatarch+1 | 89/100 | 11 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 68k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 13 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| aaif-goose/gooseAGENTS.md · 53k | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 8 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| deepseek-ai/deepseek-harnessnative/landlock-run/AGENTS.md · 104k | AGENTS.md | setupteststylearch+3 | 100/100 | today | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | today | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 201k | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+2 | 100/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/code-yeongyu-oh-my-openagent-packages-omo-opencode-src-hooks-runtime-fallback-agents)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.