Issue Title
openai-codex crashes when Codex Responses terminal event has output=null
Issue Body
Summary
When using the openai-codex provider against https://chatgpt.com/backend-api/codex, Hermes can receive usable streamed output, then fail at the terminal response.completed event with:
TypeError: 'NoneType' object is not iterable
This affects both the main Codex runtime path and auxiliary calls such as automatic title generation.
Observed behavior
Main agent call:
API call failed (attempt 1/3): TypeError
Provider: openai-codex Model: gpt-5.5
Endpoint: https://chatgpt.com/backend-api/codex
Error: 'NoneType' object is not iterable
Non-retryable client error (HTTP None). Aborting.
Auxiliary title generation:
Auxiliary title generation failed: 'NoneType' object is not iterable
The same issue was also observed with gpt-5.4.
Root cause
The Codex backend streams useful content first, including events such as:
response.output_item.done
response.output_text.delta
response.output_text.done
But the terminal response.completed event can contain a response object where:
openai-python 2.24.0 assumes response.output is iterable while parsing the terminal event:
openai/lib/_parsing/_responses.py, line 61
for output in response.output:
TypeError: 'NoneType' object is not iterable
In one path the exception is raised while iterating the stream. In another path it can be raised by stream.get_final_response(). Hermes already collected streamed output before that terminal parse failure, so the call can be recovered safely when no tool-call ambiguity exists.
Environment
Hermes: 0.14.0
Python: 3.11.15
openai-python: 2.24.0
Provider: openai-codex
Endpoint: https://chatgpt.com/backend-api/codex
Models observed: gpt-5.5, gpt-5.4
OS: Ubuntu 24.04 under WSL
Proposed fix
The patch attached below adds recovery for this null-output terminal event in both places:
Local validation
After applying the patch:
python -m py_compile agent/codex_runtime.py agent/auxiliary_client.py
passed.
Main provider call completed without the non-retryable client error:
hermes -z "Say only OK" --provider openai-codex -m gpt-5.5
Auxiliary title-generation path also completed successfully in a direct local test:
generate_title(...) -> Hermes Title Generation Fix
Patch
Patch file generated from local diff:
hermes-codex-null-output-recovery.patch
The patch changes only:
agent/codex_runtime.py
agent/auxiliary_client.py
Issue Title
openai-codex crashes when Codex Responses terminal event has
output=nullIssue Body
Summary
When using the
openai-codexprovider againsthttps://chatgpt.com/backend-api/codex, Hermes can receive usable streamed output, then fail at the terminalresponse.completedevent with:This affects both the main Codex runtime path and auxiliary calls such as automatic title generation.
Observed behavior
Main agent call:
Auxiliary title generation:
The same issue was also observed with
gpt-5.4.Root cause
The Codex backend streams useful content first, including events such as:
But the terminal
response.completedevent can contain a response object where:openai-python2.24.0 assumesresponse.outputis iterable while parsing the terminal event:In one path the exception is raised while iterating the stream. In another path it can be raised by
stream.get_final_response(). Hermes already collected streamed output before that terminal parse failure, so the call can be recovered safely when no tool-call ambiguity exists.Environment
Proposed fix
The patch attached below adds recovery for this null-output terminal event in both places:
agent/codex_runtime.pyTypeError: 'NoneType' object is not iterablecollected_output_itemsagent/auxiliary_client.py_CodexCompletionsAdapterfor event in streamstream.get_final_response()final.output is Nonelike an empty output list and backfills from collected stream eventsLocal validation
After applying the patch:
passed.
Main provider call completed without the non-retryable client error:
Auxiliary title-generation path also completed successfully in a direct local test:
Patch
Patch file generated from local diff:
The patch changes only: