Skip to content

fix(agent): recover Responses streams with null output - #32913

Closed
clarkchen wants to merge 1 commit into
NousResearch:mainfrom
clarkchen:codex-fix-responses-null-output-backfill
Closed

fix(agent): recover Responses streams with null output#32913
clarkchen wants to merge 1 commit into
NousResearch:mainfrom
clarkchen:codex-fix-responses-null-output-backfill

Conversation

@clarkchen

Copy link
Copy Markdown

Summary

Recover Codex/OpenAI Responses streams when the terminal response.output is null/None even though earlier stream events already delivered output items or text deltas.

This is the same failure mode described in #11179 and the same direction as #11182, adapted to this fork's current runtime split where the main Codex Responses stream lives in agent/codex_runtime.py rather than directly in run_agent.py.

Root Cause

Some Responses backends can emit valid response.output_item.done or response.output_text.delta events, then finish with a terminal response whose output field is null. The OpenAI SDK may raise TypeError: 'NoneType' object is not iterable while processing that terminal event, before Hermes can read the final response normally.

Changes

  • Add shared Responses output backfill helpers in agent/codex_runtime.py.
  • Recover the main Codex Responses stream path from SDK NoneType iteration crashes using collected output items or text deltas.
  • Treat terminal output=None the same as empty output in the create(stream=True) fallback.
  • Apply the same recovery to the auxiliary Responses adapter used by compression, memory, and related side-LLM flows.
  • Add regression coverage for SDK TypeError recovery and direct output=None terminal responses.

Validation

  • uv run --with pytest --with pytest-timeout --with pytest-asyncio python -m pytest tests/run_agent/test_run_agent_codex_responses.py tests/agent/test_auxiliary_client.py
  • Result: 245 passed in 65.41s

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/openai OpenAI / Codex Responses API codex duplicate This issue or pull request already exists labels May 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #32884. Same Codex null output recovery. Explicitly references #11179 and #11182 as prior art.

@clarkchen

Copy link
Copy Markdown
Author

Duplicate of #32884. Same Codex null output recovery. Explicitly references #11179 and #11182 as prior art.

@alt-glitch Thanks — confirmed, this duplicates #32884. Closing this PR in favor of that one.

@clarkchen clarkchen closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants