Skip to content

Fix reasoning summaries and orphan stream deltas#16803

Open
etraut-openai wants to merge 6 commits intomainfrom
etraut/tui_reasoning_summaries
Open

Fix reasoning summaries and orphan stream deltas#16803
etraut-openai wants to merge 6 commits intomainfrom
etraut/tui_reasoning_summaries

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Apr 4, 2026

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.

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.
@etraut-openai etraut-openai marked this pull request as ready for review April 4, 2026 18:28
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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.
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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.
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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.
@etraut-openai etraut-openai changed the title [codex] Fix reasoning summaries and orphan stream deltas Fix reasoning summaries and orphan stream deltas Apr 4, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator

jif-oai commented Apr 7, 2026

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

continue;

P2 Badge Clear buffered output deltas before plan-mode early continue

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".

Comment on lines 6029 to 6031
for delta in summary {
self.on_agent_reasoning_delta(delta);
}
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.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator

jif-oai commented Apr 7, 2026

Some comments:

  • OutputTextDelta is only buffered when there is no active item. If another item is active, early assistant text can still be attributed to the wrong items
  • Reasoning deltas/section breaks attach to whatever item is active, not specifically a reasoning item, so reordered reasoning events can also get the wrong item_id...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants