From 64c259c3e87fb193fa24bc70abc03df58d3f58e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 6 Sep 2026 15:16:11 +0000 Subject: [PATCH] fix(cli): fresh path keeps auto -> anyrouter/auto for first-turn failover (#58) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit anyr claude with no --model now leaves ANYROUTER_MODEL_MODE=auto and ANTHROPIC_MODEL=anyrouter/auto on a fresh install, instead of pinning the most-used catalog model id. Pinning a single model disables anyrouter/auto's health-aware cross-model failover chain — the first turn can then land on a degraded SKU with no fallback. The /models lookup still contributes the context-window probe used for Claude's 1M-context suffix. most_used_model_id is retained for the models list UI, which still shows the user's pinned auto model. Docs: clarify --model auto default in help text. --- src/cmd/launch.rs | 15 ++++++++------- src/help.rs | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cmd/launch.rs b/src/cmd/launch.rs index e77fea4..fbd1430 100644 --- a/src/cmd/launch.rs +++ b/src/cmd/launch.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use crate::auth::acquire_api_key; use crate::config::{write_config, DEFAULT_PROFILE}; -use crate::http::{fetch_models, most_used_model_id}; +use crate::http::fetch_models; use crate::install::ensure_tool_installed; use crate::key::{ load_config_if_present, profile_for_agent, resolve_base_url, resolve_launch_api_key, @@ -44,14 +44,15 @@ pub(crate) fn resolve_session_model( context_window: None, }; }; - let id = if is_auto_model(&requested) { - most_used_model_id(&models).unwrap_or(requested) - } else { - requested - }; + // Keep `auto` / `anyrouter/auto` as-is so the gateway applies the full + // preset failover chain on the first turn — pinning a single concrete model + // here would defeat anyrouter/auto's cross-model failover (north star: + // "fewer models that work"). The live `/models` lookup still contributes the + // context-window probe used for Claude's 1M-context suffix decision below. + let id = requested; let context_window = models .iter() - .find(|m| catalog_model_id(&m.id) == id) + .find(|m| is_auto_model(&m.id)) .and_then(|m| m.context_length); ResolvedModel { id, context_window } } diff --git a/src/help.rs b/src/help.rs index c482879..c76bbfb 100644 --- a/src/help.rs +++ b/src/help.rs @@ -12,7 +12,10 @@ Launches the coding agent through AnyRouter (signs in first if needed). Options: --yes, --ok Skip confirmation prompts (login / install) - --model auto| Session model. \"auto\" picks the most-used catalog model + --model auto| Session model. Default (no flag) = \"auto\" → \ +anyrouter/auto on a fresh install; \"auto\" resolves to the most-used \ +catalog model on an authed key, else anyrouter/auto. Omit to let failover \ +pick the best stable model per turn. --haiku Claude /model haiku and subagents --sonnet Claude /model sonnet --opus Claude /model opus