Repository navigation
fix(models): fetch ListAvailableModels from q.{region}.amazonaws.com - #293
Open
harlan-huang wants to merge 1 commit into
Open
harlan-huang wants to merge 1 commit into
harlan-huang wants to merge 1 commit into
Conversation
Since the runtime.kiro.dev migration, both api_host and q_host point at
runtime.{region}.kiro.dev, which does not implement ListAvailableModels.
AccountManager therefore skipped the request for every account and served
the static FALLBACK_MODELS list, so /v1/models drifted from what the
account can actually use: newly released models were missing, and models
disabled by organization admins were still advertised and then failed
with INVALID_MODEL_ID.
q.{region}.amazonaws.com still serves ListAvailableModels with the same
headers and returns the account's real entitlement. Add a dedicated
models_host for it, keep generation on the runtime host, and drop the
runtime-host short-circuit. FALLBACK_MODELS is still used when the fetch
fails, and a failed TTL refresh keeps the last good list.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks for the PR! 🎉 Before merge, we need a one-time CLA confirmation. Full CLA text: Please reply once with: You need to write once, all further messages from me can be ignored. |
Author
|
I have read the CLA and I accept its terms |
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
Since the
runtime.kiro.devmigration (#155),/v1/modelshas returned the staticFALLBACK_MODELSlist for every account. The gateway never asks Kiro which models the account can use. As a result:/v1/modelsINVALID_MODEL_IDRoot cause
Both hosts were moved to the runtime domain:
runtime.{region}.kiro.devdoes not implementListAvailableModels. Every variant I tried (GET and POST, both casings, with and withoutx-amz-target) returnsUnknownOperationException. To avoid that error,AccountManagerskipped the request for runtime hosts. Since every account now uses a runtime host, the dynamic fetch code never ran.q.{region}.amazonaws.comstill servesListAvailableModels. With the gateway's existingget_kiro_headers()it returns HTTP 200 and the account's real model list, including the effect of organization admin settings.Changes
kiro/config.py: newKIRO_MODELS_HOST_TEMPLATE = "https://q.{region}.amazonaws.com"andget_kiro_models_host().kiro/auth.py: newmodels_hostproperty, included in the startup log line.kiro/account_manager.py: initialization and TTL refresh request{models_host}/ListAvailableModels. The runtime-host check is removed, along with_is_runtime_endpoint(), which had no other callers.Not changed:
api_host(runtime)q_hostis still runtime and is still used by the MCP toolsFALLBACK_MODELSis used, as beforeTests
6 new tests, in
tests/unit/test_account_manager.py(TestAccountManagerModelListSource) andtests/unit/test_auth_manager.py:https://q.us-east-1.amazonaws.com/ListAvailableModelsFALLBACK_MODELSis added, and aFALLBACK_MODELSentry the account lacks is absentFALLBACK_MODELSand still closes the clientmodels_hostand updates the model-to-account mappingmodels_hostis region-specific and differs fromapi_hostFull suite:
1697 passed.Live verification
Enterprise (IAM Identity Center) account,
us-east-1:/v1/modelsreturned the 13 entries ofFALLBACK_MODELS, including models the organization had disabledmodels_host=https://q.us-east-1.amazonaws.comandFound 10 models, and/v1/modelslists exactly the models the account can callKnown limitation
Issue #58 reported that
codewhisperer.{region}.amazonaws.comdoes not exist outsideus-east-1. I could only testq.*inus-east-1. Ifq.{region}is unreachable in some region, the fetch fails and the gateway falls back toFALLBACK_MODELS, which is the current behavior, so no region should be worse off than today.Related
#285 and #289 update the static list or try to discover unlisted models. This PR fixes the cause: it fetches the list from Kiro again.
🤖 Generated with Claude Code