fix(research): inherit main model's Bedrock region prefix in sub-agent#185
Open
taxfree-python wants to merge 1 commit intohuggingface:mainfrom
Open
Conversation
The sub-agent hard-coded `bedrock/us.anthropic.claude-sonnet-4-6`, which AWS Bedrock rejects with "The provided model identifier is invalid" whenever the user runs in a region that can't reach the `us.*` cross-region inference profile (e.g. `ap-northeast-1`). Inherit the prefix the user already chose for the main model so the sub-agent picks `jp.`, `apac.`, `global.`, ... matching whatever the main agent is successfully using.
2449ec9 to
5c46551
Compare
Author
|
Note on the failing |
|
@taxfree-python the failed Claude check is expected for external fork PRs. It only runs automatically for contributors with write access to avoid potential abuse of the review workflow and repo tokens. Maintainers can still trigger it |
|
closed per maintainer request |
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.
Fixes #184.
Problem
The research sub-agent hard-codes
bedrock/us.anthropic.claude-sonnet-4-6, which AWS Bedrock rejects with"The provided model identifier is invalid."whenever the caller's region/account cannot reach theus.*cross-region inference profile (e.g.ap-northeast-1). The main agent itself is unaffected because the user-chosen profile id is passed straight through to LiteLLM — only the sub-agent overrides it.Fix
Inherit the inference-profile prefix from the main model. If the user is running
bedrock/jp.anthropic.claude-opus-4-7, the sub-agent now picksbedrock/jp.anthropic.claude-sonnet-4-6; same forglobal.,apac., etc. The sub-agent stays on the cheaper Sonnet model — only the prefix follows the main agent's choice, matching the project's existing convention of letting the user's explicit profile selection drive Bedrock routing.The existing
us.test case is preserved (the new logic still producesus.for aus.main model), and a new test coversglobal./apac.prefixes.Verification
Direct LiteLLM call from
ap-northeast-1before/after, against the same model the function returns:Unit tests pass:
Caveats
This makes the sub-agent work for every prefix under which
claude-sonnet-4-6is published on Bedrock (currentlyus.,jp.,global.). If a user is on an exotic prefix that has nosonnet-4-6variant, the sub-agent will still fail on that environment — but that's also true of the main agent on that prefix today, and addressing it would expand the scope beyond this fix.