Skip to content

Commit 9962d43

Browse files
ymuichiroCopilotmoonbox3
authored
Python: Fixed sending "text" parameter to OpenAI Responses API (#13280)
## Summary Fixed an issue where the `text` parameter was missing in requests to the OpenAI Responses API. ## Changes Made Modified the `ResponsesAgentThreadActions._generate_options()` method to correctly handle the `text` parameter: - Added to the options dictionary **only** if `text` is not `None`. - Not added if it is an empty dict (the default value). - This ensures that **only explicitly set `text` parameters** are sent to the API. ## Fix Location **File:** `semantic_kernel/agents/open_ai/responses_agent_thread_actions.py` **Before:** ```python options = { "model": merged.get("model"), "top_p": merged.get("top_p"), "temperature": merged.get("temperature"), "truncation": truncation, "metadata": merged.get("metadata"), "max_output_tokens": max_output_tokens, "parallel_tool_calls": parallel_tool_calls, } ``` **After:** ```python options = { "model": merged.get("model"), "top_p": merged.get("top_p"), "temperature": merged.get("temperature"), "truncation": truncation, "metadata": merged.get("metadata"), "max_output_tokens": max_output_tokens, "parallel_tool_calls": parallel_tool_calls, } # Add text option if it exists if merged.get("text") is not None: options["text"] = merged.get("text") ``` - Closes #13281 ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Evan Mattson <[email protected]>
1 parent 05d659d commit 9962d43

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,11 @@ def _generate_options(cls: type[_T], **kwargs: Any) -> dict[str, Any]:
11851185
"parallel_tool_calls": parallel_tool_calls,
11861186
}
11871187

1188+
# Add text option if it exists
1189+
text = merged.get("text")
1190+
if text is not None:
1191+
options["text"] = text
1192+
11881193
# Add reasoning to the options if it is provided.
11891194
# Note that non-reasoning capable models will throw an error if this is set.
11901195
if reasoning is not None:

0 commit comments

Comments
 (0)