feat(bedrock): enable OpenAI model via mantle model endpoint#2224
feat(bedrock): enable OpenAI model via mantle model endpoint#2224JackYPCOnline wants to merge 3 commits intostrands-agents:mainfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| # ``include_tool_result_status`` is intentionally excluded: it is always auto-defaulted by | ||
| # ``__init__`` and only affects Converse-side tool-result serialization. It has no effect on | ||
| # the Mantle path either way, so requiring users to clear it would be a pure footgun. | ||
| _CONVERSE_ONLY_CONFIG_KEYS: frozenset[str] = frozenset( |
There was a problem hiding this comment.
Issue: additional_args is missing from _CONVERSE_ONLY_CONFIG_KEYS. This field is splat into the Converse API request dict at line ~536 and would silently no-op on the OpenAI delegate path.
Suggestion: Add "additional_args" to _CONVERSE_ONLY_CONFIG_KEYS so that setting it alongside openai_endpoint raises at init time with a clear message, consistent with the other Converse-only fields.
There was a problem hiding this comment.
✅ Resolved — "additional_args" is now at line 98 of _CONVERSE_ONLY_CONFIG_KEYS, and there's a corresponding test case (additional_args_conflict) in the parametrized validation test.
|
Issue: This PR introduces a new public API surface ( Key API design questions worth explicit review:
|
|
Assessment: Comment Well-structured feature that cleanly extends Review Categories
The delegation pattern and test coverage (unit + integration with SigV4 signing) are well-executed. |
|
Assessment: Comment Good iteration. The previous review's critical issues have all been addressed — Remaining items
Neither is blocking — the code logic is correct and well-validated. Nice work addressing the feedback. |
|
Assessment: Approve All previously raised issues have been addressed. The code is well-structured, documentation is accurate, validation is comprehensive, and error messages are actionable. The remaining Codecov gap (82.35%, 11 missing + 4 partials) is the Non-blocking note
|
Motivation
Amazon Bedrock now exposes an OpenAI-compatible endpoint (Mantle) at
bedrock-mantle.<region>.api.aws, which provides the Responses API, Chat CompletionsAPI, and built-in features like server-side stateful conversations and reasoning
controls. These capabilities are not available through the Converse API that
BedrockModeluses today.Today, users who want to reach those capabilities have to bypass
BedrockModelandconfigure
OpenAIModel/OpenAIResponsesModelby hand with the correct base URL andauth. That's workable but leaks Bedrock routing details into application code and
splits the Bedrock experience across two provider classes depending on which API
surface the user wants.
This change lets users stay on
BedrockModeland opt into the OpenAI-compatibletransport via config.
Public API Changes
BedrockConfiggains an optionalopenai_endpointfield. When set, requests routethrough the Mantle endpoint via the OpenAI Python SDK instead of Converse; when unset,
behavior is unchanged.
The nested
OpenAIEndpointConfigholds the fields that are meaningful only on theOpenAI-compatible surface:
api(required):"responses"or"chat_completions".api_key: Bedrock-issued API key used as the bearer token. Omit to let the OpenAISDK read
OPENAI_API_KEYper AWS's documented flow.stateful: server-side conversation state (Responses only).params: pass-through to the OpenAI SDK for Responses-only options likereasoning.client_args: escape hatch for a customhttp_client(e.g. SigV4 for tests) orother SDK constructor options.
Generic inference parameters (
temperature,top_p,max_tokens) stay onBedrockConfigand are forwarded to the delegate with naming translated where theAPIs differ (for example
max_tokens→max_output_tokenson the Responses path).stop_sequencesis forwarded asstopfor Chat Completions but is rejected withapi="responses"since the Responses API does not accept stop sequences.Config that only applies to the Converse transport cannot be combined with
openai_endpoint. This includesguardrail_*,cache_*,service_tier,additional_args,streaming=False(both OpenAI delegate APIs always stream), andstop_sequenceswhenapi="responses". All such combinations raise at init timewith a specific, actionable message so misconfigurations fail loudly instead of
silently no-opping.
Use Cases
reasoning effort, built-in tools) without swapping provider classes.
OPENAI_API_KEYto a Bedrock API key and passingopenai_endpoint={"api": "chat_completions"}is typically all that's needed.
openai_endpointfor gpt-oss with reasoning, both throughBedrockModel.Backward Compatibility
Not a breaking change. The Converse path is untouched; all existing
BedrockModelconfigurations continue to work exactly as before. The only new surface is the
opt-in
openai_endpointfield.hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.