Files
semantic-kernel/python/semantic_kernel
9962d434ab 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]>
2025-10-30 06:20:13 +00:00
..
2024-10-10 22:33:42 +00:00
2024-03-28 15:10:28 +00:00