[react-ag-ui] A MESSAGES_SNAPSHOT without reasoning records erases the reasoning of earlier replies

Author: sjmattaCreated Sep 25, 2026Updated Sep 25, 2026
Labelsbug

Checklist

  • I have searched existing issues and this is not a duplicate
  • This is a reproducible bug, not a usage question

Environment info

Packages:
  @assistant-ui/react          0.15.22
  @assistant-ui/react-ag-ui    0.0.62
  @ag-ui/client                0.0.59
Also reproduced on main at 877d3da94.

Affected area(s)

Runtime / Core

Runtime adapter in use

useAgUiRuntime

Steps to reproduce

  1. Run 1 streams reasoning r1 and text a1, then RUN_FINISHED. a1 shows its reasoning.
  2. Run 2 starts with a MESSAGES_SNAPSHOT that contains u1, a1 and u2 but no reasoning records, then streams a2.

ag-ui-strands 0.4.1 sends snapshots like this: one at the start of every run and one after every model step, built only from user, assistant and tool messages. It also drops the reasoning records that assistant-ui sends back in the run input.

typescript
let run = 0;
const core = new AgUiThreadRuntimeCore({
  agent: {
    runAgent: vi.fn(async (_input, s) => {
      run += 1;
      if (run === 1) {
        reason(s, "r1", "thinking");
        say(s, "a1", "Hello.");
      } else {
        s.onMessagesSnapshotEvent?.({
          event: {
            type: "MESSAGES_SNAPSHOT",
            messages: [
              { id: "u1", role: "user", content: "hi" },
              { id: "a1", role: "assistant", content: "Hello." },
              { id: "u2", role: "user", content: "again" },
            ],
          },
        });
        say(s, "a2", "Hi again.");
      }
      s.onRunFinishedEvent?.({ event: { type: "RUN_FINISHED", threadId: "t", runId: "r" } });
      s.onRunFinalized?.({});
    }),
  } as unknown as HttpAgent,
  logger: makeLogger(),
  showThinking: true,
  notifyUpdate: () => {},
});
await core.append(userMessage("hi"));
await core.append({ ...userMessage("again"), parentId: core.getMessages().at(-1)!.id });

Expected vs actual behavior

Expected: a1 keeps the reasoning it streamed, as it does with @ag-ui/client's own message list. AbstractAgent keeps local reasoning (and activity) messages when a snapshot has none of that role.

Actual, reasoning parts per assistant message:

after run 1  [["a1", ["thinking"]]]
after run 2  [["a1", []], ["a2", []]]

In a real chat this means every reply loses its reasoning block as soon as the next run starts, and with a mid-run snapshot, before the current run even ends. Activity parts (agui-activity/<type>) are lost the same way.

Code snippet or error log

  • subscriber.ts dispatches the raw event.messages. The merged messages that @ag-ui/client passes to onMessagesSnapshotEvent still has the reasoning.
  • importMessagesSnapshot rebuilds every message in the snapshot from the snapshot alone. For messages already in the thread it merges back only tool interactions (preserveToolInteractions).

Additional context

fromAgUiMessages handles reasoning records correctly when a snapshot has them, so an agent can work around this by putting the reasoning into its snapshots (we do that now). A fix in the runtime could keep local reasoning and activity parts for messages the snapshot names when the snapshot carries no records of that role, the same rule @ag-ui/client uses. I haven't written a PR for this one.

Track in Rupic

Source: assistant-ui/assistant-ui