aaif-goose / aaif-goose/goose

Anthropic (and other providers') pre-key model list drifts because recommended_models_from_registry() exists but has no callers

オープン
#11,069 コメント 3 件 リアクション 0 件 担当者 1 名 @DOsinga が担当を希望しています GitHub で見る
主要言語
Rust
スター
54.2k
フォーク
6.2k
平均マージ
3日 4時間
マージ済み PR(30日)
240

説明

**Describe the bug**

`ANTHROPIC_KNOWN_MODELS` (`crates/goose-providers/src/anthropic.rs:32`) is a hand-maintained list that backs `ProviderDescriptor::metadata()` — what the model picker shows before an API key is configured. It has drifted twice in two months:

- `#10864` (resolved by #10865): `claude-sonnet-5` and `claude-fable-5` were missing.
- Right now, on current `main`: `claude-opus-4-1` is in the bundled canonical registry but **not** in the hardcoded list — the same gap, recurring.

Every entry is also hardcoded to a `context_limit` of `200_000`, though the registry reports up to `1_000_000` for several of these models (noted in #10864, not yet fixed).

`crates/goose-provider-types/src/canonical.rs` already has `recommended_models_from_registry(provider: &str) -> Vec` — fully implemented (filters by text-input + tool-calling support, sorts by release date, reads only the bundled registry, no network call) — with **zero callers** in the codebase. It reads as though it was written for exactly this and never wired up.

This isn't Anthropic-specific. The same `KNOWN_MODELS`-style hand-maintained pattern exists in 20+ provider files (`cursor_agent.rs`, `openai.rs`, `google.rs`, `bedrock.rs`, `xai.rs`, `openrouter.rs`, and more) — all subject to the same drift. This issue scopes to Anthropic only, as a template for the rest.

---

**To Reproduce**

1. Check the bundled canonical registry for Anthropic: `recommended_models_from_registry("anthropic")` (currently uncalled, but easy to invoke from a test) returns 11 models including `claude-opus-4-1`.
2. Compare against `ANTHROPIC_KNOWN_MODELS` in `crates/goose-providers/src/anthropic.rs` — `claude-opus-4-1` is absent.
3. Start goose with no `ANTHROPIC_API_KEY` configured — the pre-key model picker is driven by `ANTHROPIC_KNOWN_MODELS` and will not offer `claude-opus-4-1`, despite it being a valid, known Anthropic model in the bundled registry.

---

**Expected behavior**

The pre-key model picker for Anthropic should stay in sync with the bundled canonical registry automatically, instead of relying on a manually-maintained array that requires a human to notice and patch every time a new model ships (as happened with `#10864`/`#10865`, and again now with `claude-opus-4-1`).

---

**Please provide the following information**
- **OS & Arch:** N/A — code-level defect, not environment-specific
- **Interface:** UI / CLI (both consume `ProviderDescriptor::metadata()`)
- **Version:** current `main`
- **Extensions enabled:** N/A
- **Provider & Model:** Anthropic — affects the full known-model list, e.g. `claude-opus-4-1`

---

**Additional context**

Proposed approach (Anthropic first, as a template), in `AnthropicProvider::metadata()`:

1. Call `recommended_models_from_registry("anthropic")` for the primary list, sorted newest-first.
2. For each name, resolve `context_limit` via the existing `maybe_get_canonical_model("anthropic", name)` helper (already used the same way in `model.rs::with_canonical_limits`) instead of the current blanket `200_000`.
3. **Fall back to `ANTHROPIC_KNOWN_MODELS`** if the registry call returns empty (bundled registry failed to load) — no regression risk if the registry is ever unavailable.
4. **Keep legacy dated aliases** that have no registry counterpart (`claude-sonnet-4-0`, `claude-sonnet-4-20250514`, `claude-opus-4-0`, `claude-opus-4-20250514` — confirmed via a local diagnostic, verifiable via `cargo test -p goose-provider-types`) merged in alongside the registry-derived list, so existing users pinned to them don't lose them from the picker.

Net effect: the static-list-drift bug class closes for Anthropic permanently, using code that already exists and is already tested elsewhere in the same crate. Rolling the same pattern out to the other 20+ providers is a natural follow-up once this lands and the approach is validated — not proposed here.

**Verification plan**
- `cargo test -p goose-provider-types` / `-p goose-providers`
- `cargo clippy --all-targets -- -D warnings`
- Manual: start goose with no `ANTHROPIC_API_KEY` configured, confirm the model picker shows the registry-derived list plus the 4 legacy aliases, with correct per-model context limits.

Do not begin implementation until the issue reaches **Ready** on the [Goose Issues board](https://github.com/orgs/aaif-goose/projects/1).

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

The issue is in crates/goose-providers/src/anthropic.rs, specifically the ANTHROPIC_KNOWN_MODELS list. The function recommended_models_from_registry in crates/goose-provider-types/src/canonical.rs should be called to generate the list instead. Start by examining the AnthropicProvider::metadata() method and the existing maybe_get_canonical_model helper. Verify the fix by running cargo test for the relevant crates and manually checking the model picker without an API key.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
backend-api-design, tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。