Skip to content

[codex] fix Responses null output recovery - #32915

Closed
Goncalo009 wants to merge 1 commit into
NousResearch:mainfrom
Goncalo009:codex/fix-codex-none-output-stream
Closed

[codex] fix Responses null output recovery#32915
Goncalo009 wants to merge 1 commit into
NousResearch:mainfrom
Goncalo009:codex/fix-codex-none-output-stream

Conversation

@Goncalo009

@Goncalo009 Goncalo009 commented May 27, 2026

Copy link
Copy Markdown

Summary

  • omit tools from Codex Responses requests when no tools are present
  • recover Codex Responses streams when the SDK sees response.output == null
  • apply the same recovery to auxiliary/title-generation Codex streams

Root Cause

OpenAI SDK 2.24 can raise TypeError: 'NoneType' object is not iterable when the Codex backend
emits a terminal Responses stream event whose response.output is null.

Hermes treated that SDK parser failure as a local non-recoverable error, and its backfill path
only handled an empty output list rather than null. This breaks the pure Hermes openai-codex
provider with models such as gpt-5.5, and also surfaces through auxiliary title generation because
it uses the same Codex Responses stream shape.

Fix

  • omit the tools key from Codex Responses requests when no converted tools exist
  • handle response.output == null the same way as an empty output list
  • recover streamed Codex responses after the SDK parser error when text/items were already
    received
  • apply the same recovery to the auxiliary Codex adapter

Validation

  • 129 affected Codex transport/runtime/auxiliary tests passed locally
  • manual Hermes pure openai-codex gpt-5.5 CLI verification
  • manual Hermes pure WebUI verification after restart

OpenAI SDK 2.24 can raise TypeError: 'NoneType' object is not iterable when the Codex backend emits a terminal Responses stream event whose response.output is null. Hermes treated that SDK parser failure as a local non-recoverable error, and its backfill path only handled an empty output list rather than None.

This breaks the pure Hermes openai-codex provider with models such as gpt-5.5, and also surfaces through auxiliary title generation because it uses the same Codex Responses stream shape.

Fix the transport to omit the tools key when there are no converted tools, recover the main Codex stream when the SDK parser hits null output after receiving deltas, and apply the same output-none backfill/recovery behavior to the auxiliary Codex adapter.

Validation: affected Codex transport/runtime/auxiliary tests pass locally: 129 passed, 1 warning.
@Goncalo009
Goncalo009 marked this pull request as ready for review May 27, 2026 01:28
@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 (also includes tools=None guard). Competing with many other PRs for same root cause #11179.

@Goncalo009

Copy link
Copy Markdown
Author

Thanks for pointing that out. If #32884 already covers the same recovery path and the tools=None guard, I'm happy to close this PR as a duplicate.

The issue was actively affecting Codex users, and I opened this after reproducing it locally. If any part of this implementation or the extra tests around auxiliary/title-generation streams is still useful, feel free to fold it into #32884.

@Goncalo009 Goncalo009 closed this May 27, 2026
@andyylin

Copy link
Copy Markdown
Contributor

Field-tested the same failure class on a live Hermes gateway using the Codex provider (openai-codex, gpt-5.5).

Observed symptom before the fix:

TypeError: 'NoneType' object is not iterable
Non-retryable error (HTTP None) — trying fallback...

This was triggered after the stream had already emitted usable content; the SDK then failed while materializing the terminal snapshot with response.output == null.

A local hotfix matching this PR's approach — detect the null-output parser TypeError and recover from collected stream output/text before surfacing a provider failure — restored gateway responsiveness. Targeted regression covering the parser-error recovery path passed locally on the affected runtime:

tests/agent/test_codex_ttfb_watchdog.py .... [100%]
4 passed

So the root-cause analysis here matches production behavior. The important part is preserving streamed deltas/items as authoritative when the terminal Responses snapshot is malformed/null, rather than treating the SDK parser crash as an HTTP/provider failure.

@Goncalo009

Copy link
Copy Markdown
Author

Thanks for field-testing this on a live Codex gateway and for spelling out the exact failure mode.

That matches the root cause this PR was aimed at: Codex can stream usable assistant content, then the SDK raises while materializing/parsing the terminal Responses snapshot because response.output is null. The important invariant is exactly the one you called out: preserve collected streamed output items/text as authoritative, instead of surfacing the SDK parser crash as an HTTP/provider failure.

Since this PR is already closed as a duplicate, the active fix path is #32884. This field report is useful production validation for that PR.

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.

3 participants