feat(agents): improve live model discovery from provider APIs#543
Merged
Conversation
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
Closed
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
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/modelsrefresh added in #493 only worked when anANTHROPIC_API_KEYsecret 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
ANTHROPIC_API_KEYis configured, the probe now falls back toCLAUDE_CODE_OAUTH_TOKEN, sent asAuthorization: Bearerwith theanthropic-beta: oauth-2025-04-20header (same convention asvalidateClaudeToken).display_name/displayNamethrough to the picker, so live-discovered models show e.g. "Claude Opus 5" instead of a raw id.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.has_more/last_idinstead of assuming everything fits in onelimit=100page.{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.tsbecomes 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)Closes #540