Fix reasoning summaries and orphan stream deltas#16803
Fix reasoning summaries and orphan stream deltas#16803etraut-openai wants to merge 6 commits intomainfrom
Conversation
Addresses #16801 Problem: Responses streams can emit assistant or reasoning deltas before an active item exists, which can panic the CLI and omit completed reasoning summaries from the live TUI. Solution: Buffer pre-item assistant text deltas, drop orphan reasoning deltas safely, and backfill completed reasoning summaries when no live deltas were buffered.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c141e5c62
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Backfill a missing reasoning-summary prefix from the completed item snapshot when late suffix deltas streamed normally after earlier orphan deltas were dropped.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 02d2c8231c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add the required argument-comment annotation to the new reasoning-summary test helper call.
Match section breaks when reconciling completed reasoning snapshots against streamed deltas.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfb4e002eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Preserve buffered assistant text across non-message item completions so delayed assistant items can still replay early deltas.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
codex/codex-rs/core/src/codex.rs
Line 7446 in 4c903ca
In plan mode, handle_assistant_item_done_in_plan_mode(...).await can continue before the new cleanup at lines 7478-7487 runs. If pre-item OutputTextDelta bytes are buffered and an assistant OutputItemDone arrives first, that stale buffer survives and can be replayed into a later assistant item, corrupting text attribution.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for delta in summary { | ||
| self.on_agent_reasoning_delta(delta); | ||
| } |
There was a problem hiding this comment.
Preserve section breaks when backfilling completed reasoning
When streamed_reasoning is empty, this path replays summary by concatenating each part via on_agent_reasoning_delta with no separator. A completed item like summary=["part1","part2"] renders as part1part2 instead of part1\n\npart2, even though completed_reasoning is built with join("\n\n").
Useful? React with 👍 / 👎.
|
Some comments:
|
Addresses #16801
Problem: Responses streams can emit assistant or reasoning deltas before an active item exists, which can panic the CLI and omit completed reasoning summaries from the live TUI.
Solution: Buffer pre-item assistant text deltas, drop orphan reasoning deltas safely, and backfill completed reasoning summaries when no live deltas were buffered.