← Back to PRs

#8390: feat: notify user when fallback model is used (#8182)

by Glucksberg open 2026-02-04 00:24 View on GitHub →
size: M experienced-contributor
Fixes #8182 When the primary model fails and OpenClaw silently falls over to a fallback, users have no idea they're talking to a different model. **Changes:** - New `fallback-notify.ts` module with per-session dedup - Exported `FallbackAttempt` type from `model-fallback.ts` - Threaded `fallbackAttempts` through `AgentRunLoopResult` - Notification prepended to `finalPayloads` in agent-runner when a fallback is used - Example output: `⚡ Using fallback model \`anthropic/claude-haiku-3-5\` — primary \`openai/gpt-4.1-mini\` is unavailable (rate_limit)` **Dedup behavior:** - Notifies once per failover event per session - Clears tracker when primary model recovers - Re-notifies if a different fallback model is selected 9 unit tests covering all scenarios. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR threads model-fallback attempt metadata through the agent run loop and prepends a user-visible notice when a fallback model is selected instead of the configured primary. It introduces a new `fallback-notify.ts` helper with per-session deduplication behavior, exports `FallbackAttempt` from `src/agents/model-fallback.ts`, and adds unit tests covering the notification/dedup scenarios. Overall this fits cleanly into the existing `runWithModelFallback` → `runAgentTurnWithFallback` → `runReplyAgent` flow: `model-fallback` produces `attempts`, the execution layer returns them in `AgentRunLoopResult`, and `agent-runner` decides whether to emit an extra payload based on that context. <h3>Confidence Score: 4/5</h3> - This PR is largely safe to merge; changes are localized and covered by tests. - The notification logic is straightforward and threaded through existing result plumbing with minimal behavioral impact outside of adding a new user-facing message. Main concern is the module-level dedup Map potentially retaining session keys indefinitely in long-running processes. - src/auto-reply/reply/fallback-notify.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs