Repository navigation
fix(bedrock): map reasoning_effort to reasoning.effort for OpenAI GPT-5.x on Converse #38279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -418,12 +418,16 @@ def _handle_reasoning_effort_parameter(self, model: str, reasoning_effort: str, | |
| Handle the reasoning_effort parameter based on the model type. | ||
|
|
||
| - GPT-OSS models: passed through unchanged via additionalModelRequestFields. | ||
| - OpenAI GPT-5.x models: mapped to ``reasoning.effort`` via additionalModelRequestFields. | ||
| - Nova 2 models: transformed to reasoningConfig. | ||
| - Anthropic models: mapped to ``thinking`` (and ``output_config.effort`` on | ||
| adaptive Claude 4.6 / 4.7). | ||
| """ | ||
| if "gpt-oss" in model: | ||
| optional_params["reasoning_effort"] = reasoning_effort | ||
| elif "openai.gpt-5" in model: | ||
| reasoning: Final[BedrockConverseGptReasoningEffortBlock] = {"effort": reasoning_effort} | ||
| optional_params["reasoning"] = reasoning | ||
|
Comment on lines
+428
to
+430
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a Bedrock Converse deployment uses an alias without
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-existing: opaque profile ARNs map to thinking identically at merge base, for gpt-oss and Nova 2 too. Plumbing base_model through map_openai_params is out of scope.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Since opaque profile ARNs already have this behavior at merge base for GPT-OSS and Nova 2, and threading |
||
| elif self._is_nova_2_model(model): | ||
| reasoning_config: Final = self._transform_reasoning_effort_to_reasoning_config(reasoning_effort) | ||
| optional_params.update(reasoning_config) | ||
|
|
@@ -555,7 +559,7 @@ def get_supported_openai_params(self, model: str) -> list[str]: | |
| # only anthropic and mistral support tool choice config. otherwise (E.g. cohere) will fail the call - https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ToolChoice.html | ||
| supported_params.append("tool_choice") | ||
|
|
||
| if "gpt-oss" in model: | ||
| if "gpt-oss" in model or "openai.gpt-5" in model or "openai.gpt-5" in base_model: | ||
| supported_params.append("reasoning_effort") | ||
| elif self._is_nova_2_model(model): | ||
| # Nova 2 models support reasoning_effort (transformed to reasoningConfig) | ||
|
|
@@ -903,7 +907,7 @@ def map_openai_params( | |
| optional_params["_parallel_tool_use_config"] = { | ||
| "tool_choice": {"type": "auto", "disable_parallel_tool_use": not value} | ||
| } | ||
| if param == "thinking": | ||
| if param == "thinking" and "openai.gpt-5" not in model: | ||
| if ( | ||
| isinstance(value, dict) | ||
| and value.get("type") == "adaptive" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.