Skip to content

feat(react): regenerate an answer from the built-in message actions - #1607

Queued
blove wants to merge 2 commits into
mainfrom
blove/react-regenerate
Queued

blove wants to merge 2 commits into
mainfrom
blove/react-regenerate

Conversation

@blove

@blove blove commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

What

Adds Regenerate to React Chat's built-in message actions, backed by a new optional command on the core session and an implementation in the framework-neutral LangGraph session. Until now React left it out because AgentSession had no command for it.

Changes

Core

  • AgentSession gains optional regenerate?(messageId, options?). A session that cannot regenerate leaves it undefined, and callers offer no control. It rejects when the message cannot be regenerated, such as during a run. No existing session has to change.

LangGraph runtime

  • session.regenerate(messageId) finds the prompt before that assistant message, reads the thread's history, and forks from the newest saved checkpoint that does not hold that prompt yet, submitting the prompt's text there. It is built on the existing fork, so every fork rule applies after the read. The earlier answer stays on its old branch in the thread.
  • The command exists only when the transport has getHistory, getState, getRunStatus and joinStream, the capabilities fork needs.
  • It rejects for an id that is not an assistant message (without reading history), when no prompt precedes it, while a response is running, when the conversation changes while history is read, and when no such checkpoint is in the history page.

React

  • Built-in message actions accept onRegenerate(messageId) and show a Regenerate button beside Copy. It is disabled while a response is running.
  • Chat fills onRegenerate from session.regenerate when messageActions is set and the session has the command, and ignores a rejection. An app that passes its own onRegenerate keeps control. messageActions stays opt-in, so nothing changes for a Chat without it.

Limits

  • Only the history page the transport returns is searched (the SDK default is the 10 newest checkpoints), so a prompt older than that page cannot be regenerated.
  • Only the prompt's text is sent again. Input state and anything else the original submission carried are not.
  • A rejected regenerate shows nothing in Chat.
  • The AG-UI core view does not implement the command, so it shows no button there.

Verification

  • Runtime: new regenerate.spec.ts, 11 tests over a thread with two turns and a checkpoint per step: the last and an earlier answer, each rejection, and the capability gate. Inverting the checkpoint choice fails 3 of them.
  • React: new regenerate.spec.tsx, 6 tests: offered only with the command and messageActions, calls the session with the message id, app callback wins, disabled while running, works on MessageList.
  • npx nx run-many -t test,type-tests,lint -p core,react and -t test,lint,runtime-quality,runtime-type-tests -p langgraph: pass.
  • Builds of core,content,angular,react; verify-packages.mjs; verify-langgraph-candidate.mjs; inventory.mjs --check --drift warn; the 169 verifier spec tests: pass.
  • Not checked: a live LangGraph backend, or the button in a real browser. The runtime tests use a controlled transport.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadplane Ignored Ignored Preview Nov 15, 2026 10:16pm UTC

Request Review

@blove
blove added this pull request to the merge queue Nov 16, 2026
Any commits made after this event will not be merged.

This branch was successfully deployed

1 active (outdated) deployment
Preview – threadplane — 2aef5446 Deployed Nov 15, 2026 by vercel[bot]
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