Skip to content

Responses API: response.code_interpreter_call_code.delta coming back as type ResponseAudioDeltaEvent #2382

Open
@moonbox3

Description

@moonbox3

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

  1. Pip install the openai 1.82.0 package.
  2. Get a streaming response when configuring the tools like:
tools=[
  {
    "type": "code_interpreter",
    "container": { "type": "auto" }
  }
],
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions