Skip to content

fix: model-family-aware Mantle base URL resolution for OpenAI models#2922

Open
Ashutosh0x wants to merge 3 commits into
strands-agents:mainfrom
Ashutosh0x:fix/mantle-base-url-model-aware
Open

fix: model-family-aware Mantle base URL resolution for OpenAI models#2922
Ashutosh0x wants to merge 3 commits into
strands-agents:mainfrom
Ashutosh0x:fix/mantle-base-url-model-aware

Conversation

@Ashutosh0x

@Ashutosh0x Ashutosh0x commented Jun 24, 2026

Copy link
Copy Markdown

Issue

Fixes #2629

Problem

The _MANTLE_BASE_URL_TEMPLATE hardcodes /v1 for all models, but OpenAI model families require different path prefixes on Bedrock Mantle:

Model Family Required Path Example
openai.gpt-5.* (GPT-5.4, GPT-5.5) /openai/v1 https://bedrock-mantle.{region}.api.aws/openai/v1
openai.gpt-oss-* (GPT-OSS-120B) /v1 https://bedrock-mantle.{region}.api.aws/v1

As confirmed by @SummerWJLiu in #2629: flipping the template wholesale to /openai/v1 would break gpt-oss models.

Solution

Instead of a single static template, this PR adds model-family-aware URL resolution:

1. New _resolve_mantle_base_url() helper

`python
def _resolve_mantle_base_url(region: str, model_id: str | None = None) -> str:
path_prefix = 'v1'
if model_id:
for prefix in _OPENAI_PATH_MODEL_PREFIXES:
if model_id.startswith(prefix):
path_prefix = 'openai/v1'
break
return _MANTLE_BASE_URL_TEMPLATE.format(region=region, path_prefix=path_prefix)
``n

2. model_id parameter added to

esolve_bedrock_client_args()`nCallers now pass model_id to enable automatic path resolution.

3. base_url override in BedrockMantleConfig`nFor unmapped model families, users can set base_url in the config dict to bypass automatic resolution:

`python
model = OpenAIResponsesModel(
model_id='openai.new-model',
bedrock_mantle_config={'region': 'us-east-1', 'base_url': 'https://bedrock-mantle.us-east-1.api.aws/custom/v1'}
)
``n

Changes

  • _openai_bedrock.py: Added _OPENAI_PATH_MODEL_PREFIXES, _resolve_mantle_base_url(), �ase_url field in BedrockMantleConfig, and model_id param to
    esolve_bedrock_client_args()

Note

Callers of
esolve_bedrock_client_args() (in OpenAIModel and OpenAIResponsesModel) need to be updated to pass model_id. The model_id parameter defaults to None (backward compatible — falls back to /v1).

Testing

  • gpt-5.4 -> resolves to /openai/v1 path
  • gpt-5.5 -> resolves to /openai/v1 path
  • gpt-oss-120b -> resolves to /v1 path (unchanged)
  • None model_id -> resolves to /v1 path (backward compatible)
  • Explicit base_url override -> uses override (escape hatch)

Fixes strands-agents#2629

The _MANTLE_BASE_URL_TEMPLATE uses /v1 for all models, but
openai.gpt-5.* models require /openai/v1. This adds a
_resolve_mantle_base_url() helper that keys the path off the
model_id, plus a base_url override in BedrockMantleConfig for
unmapped model families.
@github-actions github-actions Bot added size/s bug Something isn't working python Pull requests that update python code area-model Related to models or model providers labels Jun 24, 2026
@github-actions github-actions Bot added size/l and removed size/s labels Jun 24, 2026
@github-actions github-actions Bot added size/s and removed size/l labels Jun 24, 2026
@Ashutosh0x

Copy link
Copy Markdown
Author

Note: This PR currently only modifies _openai_bedrock.py with the model-family-aware resolver. The callers (OpenAIModel and OpenAIResponsesModel) need a one-line update each to pass model_id:

`python

In openai.py (line ~144) and openai_responses.py (line ~198):

Before:

return resolve_bedrock_client_args(self._bedrock_mantle_config, self.client_args)

After:

return resolve_bedrock_client_args(self._bedrock_mantle_config, self.client_args, model_id=self.config.get('model_id'))
``n
The model_id param defaults to None (backward compatible, falls back to /v1), so the core fix is safe to merge independently. Happy to add the caller updates in a follow-up commit if preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-model Related to models or model providers bug Something isn't working python Pull requests that update python code size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bedrock_mantle_config builds wrong base_url for OpenAI Responses models (missing /openai path segment)

1 participant