Skip to content

feat(agents): improve live model discovery from provider APIs#543

Merged
jonwiggins merged 1 commit into
mainfrom
feat/live-model-refresh-improvements
Jun 10, 2026
Merged

feat(agents): improve live model discovery from provider APIs#543
jonwiggins merged 1 commit into
mainfrom
feat/live-model-refresh-improvements

Conversation

@jonwiggins

Copy link
Copy Markdown
Owner

Summary

Follow-up to #542 that addresses the second half of #540 (using Anthropic's models endpoint so new models show up without a code change).

The live /v1/models refresh added in #493 only worked when an ANTHROPIC_API_KEY secret was configured. Deployments using the recommended OAuth token mode silently fell back to the hardcoded baseline catalog — which is the likely reason Opus 4.8 didn't appear and #540 was filed.

Changes

  • OAuth token fallback for the Anthropic probe — when no ANTHROPIC_API_KEY is configured, the probe now falls back to CLAUDE_CODE_OAUTH_TOKEN, sent as Authorization: Bearer with the anthropic-beta: oauth-2025-04-20 header (same convention as validateClaudeToken).
  • Display names — the Anthropic and Gemini probes now carry display_name/displayName through to the picker, so live-discovered models show e.g. "Claude Opus 5" instead of a raw id.
  • Family inference — live models whose id contains a baseline family name (opus, sonnet, haiku, fable, …) are assigned to that family, so they group under the right heading in the grouped dropdown instead of each forming a single-model group.
  • Pagination — the Anthropic probe follows has_more/last_id instead of assuming everything fits in one limit=100 page.
  • Cache shape — the Redis cache now stores {id, displayName} entries; the legacy ids-only shape is still readable, so existing cache entries survive the deploy.

With this, the baseline catalog in packages/shared/src/agent-options/anthropic.ts becomes a true fallback: future model releases appear in the picker automatically on the next refresh.

Testing

  • packages/shared: 423 tests pass (new coverage for displayName labels, family inference, grouping)
  • apps/api: 2105 tests pass (new coverage for OAuth fallback headers, pagination, display names, legacy cache shape)
  • Typecheck clean across all packages

Closes #540

The /v1/models live refresh added in #493 only worked when an
ANTHROPIC_API_KEY secret was configured, so deployments using the
recommended OAuth token mode silently fell back to the hardcoded
baseline — the likely reason new models like Opus 4.8 didn't appear
(#540).

- Fall back to CLAUDE_CODE_OAUTH_TOKEN (Bearer + oauth beta header)
  for the Anthropic models probe when no API key is configured
- Carry display_name from the Anthropic/Gemini list-models responses
  through to model labels instead of showing raw ids
- Infer the family of live-discovered models from baseline families
  so they group under Opus/Sonnet/Haiku in the picker instead of each
  forming a single-model group
- Follow has_more/last_id pagination on the Anthropic models endpoint
- Cache shape now stores {id, displayName} entries; legacy ids-only
  entries are still readable

Closes #540
@jonwiggins jonwiggins mentioned this pull request Jun 10, 2026
@jonwiggins jonwiggins merged commit 82a513b into main Jun 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opus 4.8 Support?

1 participant