Open
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
While using the new code interpreter functionality with the OpenAI package v1.82.0, and streaming events, the event for a response.code_interpreter_call_code.delta
is coming back as part of ResponseAudioDeltaEvent
instead of as part of ResponseCodeInterpreterCallCodeDeltaEvent
:
Here are the events I receive:
event
ResponseCodeInterpreterCallInProgressEvent(code_interpreter_call=None, output_index=0, sequence_number=3, type='response.code_interpreter_call.in_progress', item_id='ci_68355305cb2881919aabe46ca6725a2403aa3f9ee87e93d4')
Then:
event
ResponseAudioDeltaEvent(delta='import', sequence_number=4, type='response.code_interpreter_call_code.delta', output_index=0, item_id='ci_68355305cb2881919aabe46ca6725a2403aa3f9ee87e93d4')
To Reproduce
- Pip install the
openai
1.82.0 package. - Get a streaming response when configuring the tools like:
tools=[
{
"type": "code_interpreter",
"container": { "type": "auto" }
}
],
- The response will be of type
ResponseAudioDeltaEvent
but contain the following:
event
ResponseAudioDeltaEvent(delta='import', sequence_number=4, type='response.code_interpreter_call_code.delta', output_index=0, item_id='ci_68355305cb2881919aabe46ca6725a2403aa3f9ee87e93d4')
I handle streaming events in the a similar way to (that all emit the correct event types):
response: AsyncStream[ResponseStreamEvent] = await agent.client.responses.create(
input="Give me the first 10 fibonacci numbers using Python",
instructions=<instructions>,
previous_response_id=previous_response_id,
store=store_output_enabled,
tools=tools, # configured for code interpreter
stream=True,
**response_options,
)
async with response as response_stream:
async for event in response_stream:
event = cast(ResponseStreamEvent, event)
match event:
case ResponseCreatedEvent():
# Removed for brevity
pass
case ResponseOutputItemAddedEvent():
# Removed for brevity
pass
case ResponseFunctionCallArgumentsDeltaEvent():
# Removed for brevity
pass
case ResponseCodeInterpreterCallCodeDeltaEvent():
# Expect to hit this case, but I do not.
pass
Code snippets
See above.
OS
MacOS Sequoia 15.5
Python version
Python 3.12.10
Library version
openai 1.82.0