Repository navigation
Python: [Bug]: Streamed code interpreter outputs (logs/images) are always empty #9743
Description
Description
Streaming a code interpreter call's outputs (logs, generated images) through OpenAIChatClient always produces an empty code_interpreter_tool_result.outputs, regardless of what the sandbox actually produced.
response.output_item.done handles every other hosted-tool item type by capturing its final, complete state there - shell_call, computer_call, computer_call_output, image_generation_call, mcp_call, web_search_call/file_search_call, custom_tool_call, tool_search_call, function_call_output all have a branch in that event's dispatch, several with a comment explicitly noting the completed item is the only place their full data is populated. code_interpreter_call has no branch there at all. The only other place code interpreter outputs are read from is response.output_item.added, which fires before the call has run, so outputs is always empty/None at that point.
There is no incremental "outputs delta" event for code interpreter calls, so with neither event ever delivering the populated outputs, a streamed code_interpreter_tool_result is silently always empty.
Expected behavior
The logs/images a code interpreter call actually produced should show up in the streamed response's code_interpreter_tool_result.outputs, the same as they already do for a non-streaming get_response() call (_parse_response_from_openai does have a code_interpreter_call branch and reads outputs correctly there).
Actual behavior
from unittest.mock import MagicMock
from agent_framework import ChatResponse
from agent_framework_openai import OpenAIChatClient
client = OpenAIChatClient(model="test-model", api_key="test-key")
added = MagicMock(type="response.output_item.added")
added.item = MagicMock(type="code_interpreter_call", call_id="ci_1", code=None, outputs=None)
log_output = MagicMock(type="logs", logs="pandas 2.1.0")
done = MagicMock(type="response.output_item.done")
done.item = MagicMock(type="code_interpreter_call", call_id="ci_1", code="import pandas as pd", outputs=[log_output])
updates = [
client._parse_chunk_from_openai(added, {}, {}),
client._parse_chunk_from_openai(done, {}, {}),
]
resp = ChatResponse.from_updates(updates)
result = next(c for c in resp.messages[0].contents if c.type == "code_interpreter_tool_result")
print(result.outputs) # [] - the "pandas 2.1.0" log line never shows upCode Sample
(same as above)
Error Messages / Stack Traces
No exception is raised. The result is just silently empty, so an application displaying or forwarding code interpreter output sees nothing, with no indication anything went wrong.
Package Versions
agent-framework-core: 1.23.0, agent-framework-openai: 1.17.0
Python Version
Python 3.12
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Oct 27, 2026
🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
The bug reproduces in
python/packages/openai/agent_framework_openai/_chat_client.py::RawOpenAIChatClient._parse_chunk_from_openai, whereresponse.output_item.doneat lines 4441-4524 does not processcode_interpreter_callitems containing completed outputs. Minimal repro: parse an emptyresponse.output_item.added, then a completed item containing log and image outputs, merge the updates withChatResponse.from_updates, and observe an empty result output list.python/packages/openai/tests/openai/test_openai_chat_client.py::test_parse_chunk_from_openai_code_interpreter_uses_completed_outputs1.17.01.17.0Python: Capture code interpreter outputs on output_item.done (microso…