Skip to content

fix(codex): tolerate None output responses - #32926

Closed
xXKillerNoobYT wants to merge 2 commits into
NousResearch:mainfrom
xXKillerNoobYT:wei-2678-codex-nonetype-crash
Closed

xXKillerNoobYT wants to merge 2 commits into
NousResearch:mainfrom
xXKillerNoobYT:wei-2678-codex-nonetype-crash

Conversation

@xXKillerNoobYT

Copy link
Copy Markdown

Summary

  • omit null tools from Codex Responses kwargs so the OpenAI SDK does not iterate None
  • route SDK output=None parser TypeErrors through the existing raw stream fallback
  • safely read output_text when SDK response.output is None
  • backfill stream output for both output=[] and output=None in main and auxiliary Codex paths

Verification

  • venv/bin/python -m pytest tests/agent/transports/test_codex_transport.py tests/agent/test_codex_runtime.py tests/agent/test_auxiliary_client.py::TestCodexAuxiliaryAdapterTimeout -q
  • Live smoke: Hermes openai-codex/gpt-5.5 no longer aborts with TypeError: 'NoneType' object is not iterable; current upstream returns empty response.output and Hermes reports that as an invalid API response after retries instead of masking it as NoneType.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Copilot AI review requested due to automatic review settings May 27, 2026 01:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Improves robustness of Codex Responses streaming/normalization when the upstream SDK returns output=None, and ensures tool payloads are omitted when no tools are available.

Changes:

  • Omit tools from Codex request kwargs when tools is None/empty.
  • Add safer output_text access to prevent crashes when response.output is None.
  • Harden streaming logic to retry/fallback when the SDK parser hits output=None, with new tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/agent/transports/test_codex_transport.py Adds regression test ensuring tools is omitted when not provided.
tests/agent/test_codex_runtime.py Adds tests for stream retry/fallback behavior on output=None TypeError.
agent/transports/codex.py Stops sending tools key when response_tools is empty/None.
agent/conversation_loop.py Uses safe output text accessor in output_text fallback path.
agent/codex_runtime.py Backfills output when missing/non-list; retries/falls back on SDK TypeError for output=None.
agent/codex_responses_adapter.py Introduces _safe_get_response_output_text and uses it during normalization.
agent/auxiliary_client.py Aligns output backfill condition with codex runtime behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread agent/codex_runtime.py Outdated
# Backfill from collected items or synthesize from deltas.
_out = getattr(final_response, "output", None)
if isinstance(_out, list) and not _out:
if not isinstance(_out, list) or not _out:
Comment thread agent/codex_runtime.py Outdated
Comment on lines 437 to 439
if not isinstance(_out, list) or not _out:
if collected_output_items:
terminal_response.output = list(collected_output_items)
Comment thread agent/auxiliary_client.py Outdated
# Backfill empty output from collected stream events
_output = getattr(final, "output", None)
if isinstance(_output, list) and not _output:
if not isinstance(_output, list) or not _output:
Comment thread agent/codex_runtime.py Outdated
raise
except TypeError as exc:
err_text = str(exc)
sdk_output_none = "'NoneType' object is not iterable" in err_text
Comment thread tests/agent/test_codex_runtime.py Outdated
Comment on lines +37 to +40
_interrupt_requested = False
_codex_streamed_text_parts = []

def __init__(self):
Comment thread agent/conversation_loop.py Outdated
Comment on lines +1227 to +1228
from agent.codex_responses_adapter import _safe_get_response_output_text
_out_text = _safe_get_response_output_text(response)
@xXKillerNoobYT

Copy link
Copy Markdown
Author

@NousResearch/hermes-agent maintainers — this PR (head 987e002) addresses the upstream Codex response.output=None crash. CI is green on focused tests (52 passed on the updated branch, 51 passed on the runtime checkout). Could a maintainer please review and squash-merge when convenient? Authoring account lacks push/merge on this repo and self-approval would violate review integrity. Happy to address any review feedback.

@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
Contributor

Duplicate of #32884 — same Codex Responses null output recovery. Root cause tracked in #11179.

@xXKillerNoobYT

Copy link
Copy Markdown
Author

Thanks @alt-glitch — appreciated the triage. Happy to defer to the maintainer call on which vehicle to land. We will track #32884 alongside #32926 and accept whichever you all choose to squash-merge. The underlying root cause #11179 is the priority; either landing resolves the downstream consumer. Will not push further changes to #32926 unless maintainers prefer this branch — let us know if you'd like us to close ours in favor of #32884.

@teknium1

Copy link
Copy Markdown
Collaborator

Closing as duplicate — the Codex null-output fix has been merged via #32963 (cherry-picked from @carltonawong's PR #32890, the one Gille reviewed). Thanks for jumping on the outage so quickly; appreciate the help. Closes #11179.

@teknium1 teknium1 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.

4 participants