← Back to PRs

#10178: fix: trigger fallback when model resolution fails with unknown model

by Yida-Dev open 2026-02-06 06:26 View on GitHub →
agents stale
## Summary - When a model is unknown (e.g. `claude-opus-4-6` not yet available for setup-token auth), the error was thrown as a plain `Error` before the fallback mechanism could intercept it - Added `isUnknownModelErrorMessage()` to detect "Unknown model" / "Model not found" errors - `classifyFailoverReason()` now classifies these as `"auth"` (model availability is auth-mode-dependent) - When fallback is configured, `run.ts` now throws `FailoverError` instead of plain `Error`, allowing the agent to retry with the fallback model - Added regression test for the new error classification Closes #10088 ## Test plan - [x] Existing `classifyFailoverReason` tests pass (no regressions) - [x] New test: `classifies unknown model errors as auth` passes - [x] `pnpm vitest run src/agents/pi-embedded-helpers.classifyfailoverreason.test.ts` — 3 tests pass 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates embedded-agent failover classification to treat “Unknown model” / “Model not found” errors as an `auth` failover reason, and changes the embedded runner to throw `FailoverError` (instead of a plain `Error`) when model resolution fails and fallbacks are configured. It also adds a regression test covering the new classification. These changes integrate with the existing failover pipeline by ensuring model-resolution failures can be intercepted by the retry/fallback mechanism (`FailoverError` + `classifyFailoverReason`). <h3>Confidence Score: 4/5</h3> - Mostly safe to merge, but fix the new test compile error first - Behavioral change is small and localized (new unknown-model classification and throwing FailoverError when fallback is configured). However, the added test file references an unimported type, which will break TypeScript builds/typecheck in environments that include tests. - src/agents/pi-embedded-helpers.classifyfailoverreason.test.ts <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs