fix(codex): render reasoning summaries from both CLI output shapes#1078
Conversation
Codex emits the reasoning `summary` field in two shapes depending on CLI
version: a plain `string[]` (older app-server) and an
`Array<{ type: 'summary_text', text }>` (newer Responses API). The parser
previously dropped every reasoning payload to a non-displayable `system`
event, so the model's thinking was never shown for either shape.
Add `extractReasoningSummaryText()` to normalize both shapes into display
text, emit it as partial reasoning text (run through `formatReasoningText`),
and fall back to a `system` event only when there is no plain-text summary
(encrypted_content only, or blank strings). Covered by four new parser tests.
|
PR changed again? Review this PR in Change Stack to compare snapshots and stay oriented. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR extends the Codex output parser to properly handle and emit reasoning summaries from response items. It adds a helper function to normalize reasoning text from multiple payload shapes and updates the parser to emit text events marked as reasoning-specific, or fall back to system events when no displayable summary is available. ChangesReasoning Summary Extraction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes reasoning-summary rendering so both the older
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to the reasoning payload branch of the parser, with no impact on other event types. The new helper is well-guarded (unknown input, explicit Array.isArray check, per-entry type narrowing, blank-string filtering), the fallback to a system event is preserved for encrypted-only payloads, and four targeted test cases verify each code path. No existing behaviour is removed. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["response_item (payload.type = reasoning)"] --> B["extractReasoningSummaryText(payload.summary)"]
B --> C{"Array.isArray and length > 0?"}
C -- No --> D["return empty string"]
C -- Yes --> E["Iterate entries"]
E --> F{"string entry?"}
F -- "Yes, non-blank" --> H["push entry"]
F -- "Yes, blank" --> E
F -- No --> I{"object entry?"}
I -- "type=summary_text, non-blank" --> K["push obj.text"]
I -- No --> E
H --> E
K --> E
E --> L["parts.join newline then trim"]
L --> M{"summaryText truthy?"}
D --> M
M -- Yes --> N["formatReasoningText(summaryText)"]
N --> O["return type=text, isReasoning=true"]
M -- No --> P["return type=system"]
Reviews (1): Last reviewed commit: "fix(codex): render reasoning summaries f..." | Re-trigger Greptile |
|
Thanks for the contribution, @jSydorowicz21! 🙏 I reviewed the change along with the CodeRabbit and Greptile passes, and this looks great:
CodeRabbit reported no actionable comments and Greptile scored it 5/5 "safe to merge." No merge conflicts against |
@-
Summary by CodeRabbit
Bug Fixes