fix(codex): harden Responses streaming against terminal-shape drift - #33755
Closed
alexpartisan wants to merge 1 commit into
Closed
fix(codex): harden Responses streaming against terminal-shape drift#33755alexpartisan wants to merge 1 commit into
alexpartisan wants to merge 1 commit into
Conversation
- switch codex stream consumption to responses.create(stream=True) event-driven assembly - align auxiliary codex path with the same event consumer - omit tools field when no tools are available (avoid None iterable path) - classify NoneType/not-iterable provider shape failures as retryable in conversation loop
Contributor
|
Thanks for this — closing as already fixed on The Codex null-output crash (
Your fix targets the same path that's now hardened upstream, so there's nothing left to merge here. Your authorship is preserved in your branch; I'm crediting your report in the umbrella issue #33932 (now closed). Appreciate the contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens Hermes' Codex Responses streaming path against provider/SDK payload-shape drift that was producing user-visible failures in Weixin and CLI flows.
Problem
In production, we observed these recurring error patterns:
TypeError: 'NoneType' object is not iterableNon-retryable error (HTTP None)Responses create(stream=True) fallback did not emit a terminal responseThese failures were intermittent and often surfaced as misleading non-retryable client errors, despite being upstream stream-shape compatibility issues.
Root Cause
The previous Codex path depended on high-level typed reconstruction behavior that could break when terminal response payloads had shape drift (e.g. null/empty output structures). In some paths,
toolshandling could also trigger pre-request iterable errors when effectively empty.Changes
1) Event-driven Codex stream consumption
responses.create(stream=True)event consumption._consume_codex_event_streamto assemble final response from streamed events (response.output_item.done, deltas, terminal events) rather than relying on fragile terminal payload reconstruction.2) Auxiliary path alignment
3) Safer tools serialization
toolsentirely when no tools are available (instead of passing an empty/null-like shape).4) Error classification resilience
NoneType not iterablepattern so normal retry/fallback can proceed.Files Changed
agent/codex_runtime.pyagent/auxiliary_client.pyagent/transports/codex.pyagent/conversation_loop.pyValidation
gateway_state=runningandweixin=connected.Risk / Compatibility