Python: Exclude conversation_id from chat completions API options (#4517)

* Python: Exclude conversation_id from chat completions options (#4315)

When a session with service_session_id is passed to an agent using the
Chat Completions client, conversation_id leaked through _prepare_options()
into AsyncCompletions.create(), causing an 'unexpected keyword argument'
error. The Responses client already excluded conversation_id but the Chat
Completions client did not.

Added conversation_id to the exclusion set in _prepare_options().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Apply pre-commit auto-fixes

* Remove reproduction report artifact

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Evan Mattson
2026-03-10 02:03:50 +09:00
committed by GitHub
Unverified
parent f74bda5a83
commit 2aaca50217
3 changed files with 85 additions and 1 deletions
@@ -1161,6 +1161,21 @@ def test_prepare_options_removes_parallel_tool_calls_when_no_tools(openai_unit_t
assert "parallel_tool_calls" not in prepared_options
def test_prepare_options_excludes_conversation_id(openai_unit_test_env: dict[str, str]) -> None:
"""Test that conversation_id is excluded from prepared options for chat completions."""
client = OpenAIChatClient()
messages = [Message(role="user", text="test")]
options = {"conversation_id": "12345", "temperature": 0.7}
prepared_options = client._prepare_options(messages, options)
# conversation_id is not a valid parameter for AsyncCompletions.create()
assert "conversation_id" not in prepared_options
# Other options should still be present
assert prepared_options["temperature"] == 0.7
async def test_streaming_exception_handling(openai_unit_test_env: dict[str, str]) -> None:
"""Test that streaming errors are properly handled."""
client = OpenAIChatClient()