Skip to content

Python: [Bug]: Streamed code interpreter outputs (logs/images) are always empty #9743

Closed

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 up

Code 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

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 27, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Oct 27, 2026
  3. github-actions commented on Oct 27, 2026

    @github-actions
    Contributor

    🤖 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, where response.output_item.done at lines 4441-4524 does not process code_interpreter_call items containing completed outputs. Minimal repro: parse an empty response.output_item.added, then a completed item containing log and image outputs, merge the updates with ChatResponse.from_updates, and observe an empty result output list.

    • Failing test: python/packages/openai/tests/openai/test_openai_chat_client.py::test_parse_chunk_from_openai_code_interpreter_uses_completed_outputs
    • Files examined: python/packages/openai/agent_framework_openai/_chat_client.py, python/packages/openai/tests/openai/test_openai_chat_client.py, python/packages/openai/pyproject.toml
    • Tests run: existing code interpreter parser tests, test_parse_chunk_from_openai_code_interpreter_uses_completed_outputs
    • Reported version: 1.17.0
    • Current version: 1.17.0
  4. added
    agentsUsage: [Issues, PRs], Target: Single agent
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 27, 2026
  5. added a commit that references this issue on Oct 27, 2026
    10a94cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions