Repository navigation
Add per-bot fallback model for transient failures and quota limits - #381
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets each bot configure an optional fallback model so turns, unattended Routines, and Checks automatically recover when the primary model fails due to rate limits (HTTP 429), quota exhaustion (
usage_limit_exceeded/insufficient_quota), 5xx server errors, or network/stream errors:proto/src/lib.rs,PROTOCOL.md): AddsOp::FallbackModel { model }andEvent::Fallback { from, to, error }, plus optionalfallbackModelonset_botandBot.agentcore/src/{model,turn,main,acp}.rs): Tracksfallback_eligibleandstreamedon model failures. When the primary model fails before streaming any output — immediately on quota 429, or after primary retries exhaust on rate-limit 429 / 5xx / network errors —Turn::stream_untilemitsEvent::Fallbackand switches to the fallback model for the rest of that turn (returning to the primary model on the next turn).appd/src/{store,core}.rs): Addsfallback_models(inBOT_TABLES,ON DELETE CASCADE), validatesfallbackModelviacheck_model, persists it across restarts, and forwardsOp::FallbackModelon engine start andset_bot.window/ui,native): Rendersfallbacktranscript entries as a quiet status line in both chat views, and adds a Fallback group with a Fallback model picker in Bot Settings (refreshing Bot Settings snapshots; visually verified in light and dark themes).Closes #374.
Evidence
cd window/ui && npm ci && npm run build && npm test: passed (142/142 tests, including newchat.test.tsfallback entry test).cargo fmt --all --check: passed.cargo clippy --workspace --all-targets --locked -- -D warnings: passed.cargo test --workspace --locked --no-fail-fast: passed across all crates, including:agentcore/tests/engine.rs::falls_back_to_backup_model_after_primary_503_retries_exhaust_and_on_quota_429appd/tests/service.rs::fallback_model_persists_across_restarts_and_can_be_clearedappd/src/store.rs::deleting_a_bot_or_a_project_leaves_no_row_that_points_at_it(fallback_modelscascade verified)native/tests/bot_settings.rs::fallback_model_is_chosen_and_cleared_with_set_bot+ visually inspected updated light/dark Bot Settings snapshots.Merge Danger
Low. Adds a new
fallback_modelstable (listed inBOT_TABLES) and optionalfallbackModelfield; when unset (the default), engine and service behavior are unchanged.Device decision
fallbackModelis carried onset_botandlist_bots/open_bot, which are already inALLOWED_OVER_LAN(alongsideset_model). A paired Device may read and change a bot's fallback model, matchingset_modelandset_botwithout weakeningcheckrestrictions.