Skip to content

🧩 fix: Keep Streamed Parts Intact Across Replays and Early Completions - #16331

Merged
berry-13 merged 1 commit into
canaryfrom
berry-13/step-reducer-fixes
Sep 24, 2026
Merged

berry-13 merged 1 commit into
canaryfrom
berry-13/step-reducer-fixes

Conversation

@berry-13

@berry-13 berry-13 commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

The step reducer refactor (#16289, #16290) carried over four streaming defects unchanged on purpose. This change fixes all four in the reducer and its adapter hook. Each part still sits at its step index, and nothing is spliced mid-stream.

A finalized summary now keeps the agentId/groupId of its in-flight part when the completed summary omits them, so a parallel agent's summary stays in its column. The first streamed image_url part now gets the incoming URL instead of an empty clone of the placeholder slot. A tool_calls run step announced again after its call settled leaves the settled part alone. The resume path re-dispatches every known run step as ON_RUN_STEP, and that used to reset a completed card to running. An ON_RUN_STEP_COMPLETED that arrives before its run step is now buffered like the other pre-step events, where it used to be dropped with a warning.

berry-13#111
berry-13#113
berry-13#115
berry-13#116

Type of change

  • Bug fix

Testing

Each fix has a regression test that failed before the change: three reducer cases in steps.spec.ts (summary metadata, first image URL, re-announced settled tool call) and one hook case in useStepHandler.spec.ts (completion before its run step, including the skill-authoring signal firing once). The old test that asserted the drop warning is replaced by the buffering case.

Tested environments/configuration:

  • Local dev build via lc (backend serving this branch's client/dist), headless Chromium, agents endpoint with a Claude Sonnet 4.6 agent carrying the Tavily search tool.
  • Reconnect: sent a prompt that searches and then writes a long essay, waited for the tool group to settle while the answer was still streaming, then reloaded the page so the resumable stream reconnected. The settled group stayed "Ran 2 actions" through the resume and to the end of the stream while a new call showed as running, and the console had no "No run step" or "Content type mismatch" warnings.
  • Not reproduced at runtime: the streamed image part (no image-output Gemini model is configured here; the producer is @langchain/google-common, which turns Gemini inlineData output into streamed image_url parts) and a summarize round (nothing in this configuration triggers agent compaction short of filling the context window). Both are covered by the reducer tests above.

Automated tests:

  • cd client && npx jest hooks/SSE: 10 suites, 386 tests passed
  • cd client && npm run typecheck: clean
  • npx eslint, npx prettier --check, node scripts/sort-imports.mts --check on the six changed files: clean

Screenshots / recordings

No visual change. The attached captures are from the reconnect run on this branch: before the reload, right after the resume, and at the end of the stream.

Risk / compatibility

A completion whose run step never arrives now stays in the pending buffer until the next clearStepMaps instead of being dropped. The buffer is cleared at every run boundary, as it already is for buffered deltas.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors

Before the reload: tool group settled, answer streaming

Right after the resume: settled group unchanged

End of the stream

- Carry the in-flight summary's agentId/groupId onto the finalized part
  when the completed summary omits them.
- Write the incoming image_url into a new image slot instead of cloning
  the empty placeholder.
- Leave a settled tool call alone when its tool_calls run step is
  announced again, as the resume path does for every known run step.
- Buffer an ON_RUN_STEP_COMPLETED that arrives before its run step and
  apply it when the step lands, like the other pre-step events.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T23:00:54.745904Z 88e1dff Draft marked ready
🔒 Security Review ✅ Completed 2026-09-24T23:03:31.824651Z 88e1dff Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant