Skip to content

feat(ag-ui): answer interrupts through the core resume command - #1677

Merged
blove merged 24 commits into
mainfrom
blove/ag-ui-core-resume
Nov 20, 2026
Merged

blove merged 24 commits into
mainfrom
blove/ag-ui-core-resume

Conversation

@blove

@blove blove commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The AG-UI session's resume is now the core contract's command, and its snapshot publishes the core interrupts and subagents. With this, an AG-UI session is a core AgentSession including pause and resume.

const { interrupts } = session.getSnapshot();
await session.resume(
  (interrupts ?? []).map((interrupt) => ({
    interruptId: interrupt.id,
    status: 'resolved',
    value: { approved: true },
  }))
);

Includes #1675. #1659 has merged, and with it on main #1675 can no longer pass on its own: the AG-UI session is now typed as a core session, so the core resume and subagents that #1675 adds need the AG-UI changes in this PR to compile. This PR carries both. The commit specific to this PR is feat(ag-ui): answer interrupts through the core resume command and publish core child agents; the rest of the diff is #1675 (core contract, LangGraph session and its callers).

Breaking changes

  • resume(pause, responses) is now resume(responses). There is no pause token to pass: the session answers the pause that is pending. decision.id is still published.
  • A response carries value, not payload. The request and decision.attempt.responses still carry the protocol's payload. A response may still carry the protocol's optional metadata.
  • resume rejects instead of resolving 'error' when it cannot send what was asked: nothing is waiting, the pausing run has not settled, an answer was already sent, a run is active, an interrupt has expired, a response names an interrupt that is not pending or names one twice, or an interrupt is left unanswered. It still resolves 'aborted' after disposal or with an aborted signal, and with the run's outcome once the answer is sent.
  • snapshot.subagents entries are core child agents. Each has id, status, its own messages and toolCalls, and name, description, toolCallId, parentId, error when known. The protocol evidence stays on each entry as started and terminal, so code that reads those keeps working. earlierSubagents is unchanged.

Added

  • snapshot.interrupts: the pending interrupts, from the pause until an answer is sent. Absent when nothing is waiting and for a pause the session cannot answer.

Why the child agents are in this PR

The core contract added subagents in #1675, and the AG-UI snapshot already had a field of that name holding protocol evidence. The session could not satisfy the core type until that field held core children, so this PR does it rather than renaming the field.

Things to know

  • A finished child is complete even when its outcome is suspended; this matches what React Chat already shows.
  • A child's records are matched by run id, so a later child that reuses an id also lists the earlier child's records. React Chat attributes messages the same way today.
  • One test was removed: it only proved that another session's pause token is refused, and there is no token now. Stale-token assertions inside three other tests were removed for the same reason.

Verification

  • nx run-many -t runtime-quality,runtime-type-tests,test,type-tests,lint -p core,ag-ui,langgraph,react,angular passes.
  • nx run-many -t test,lint for the 10 AG-UI and runtime cockpit React apps passes.
  • All cockpit React apps, the AG-UI fixtures and the Mastra runner type-check against source.
  • node --test scripts/react-parity/ag-ui-candidate-package.spec.mjs: 28 pass. inventory.mjs --check --drift warn passes.
  • Mutation checks: publishing interrupts after an answer is sent, and reporting a failed child as complete, each fail the new tests.
  • Not run locally: verify-ag-ui-candidate.mjs, verify-ag-ui-client-tools.mjs, the native browser fixtures, the Mastra runner itself, and Playwright e2e. The machine was too loaded for the package verifiers to finish.

🤖 Generated with Claude Code

blove and others added 22 commits November 17, 2026 20:12
AgentSession and AgentSnapshot take a second type parameter for application
state. The snapshot gains an optional, deeply readonly `state`, and `submit`
accepts `{ message, state }` with a partial state as well as plain text.

A session is told its state type by one declaration: `type<T>()` for the type
alone, or any Standard Schema value to also check each state as it arrives.
`readState` runs that check for session implementations. The fake session
holds, sets and validates state the same way.

No backend session supplies `state` yet; LangGraph and AG-UI follow.
createSession takes a stateType, either type<T>() or a Standard Schema.
createAgentSession publishes the state document as the typed state of the
core snapshot, checks it once per document when a schema is declared, and
reports a rejected document in stateIssues without failing the run. A
session created without a state reports none until one is supplied.
The session createSession returns now publishes the core snapshot itself:
messages, tool calls, error, usage and typed state beside the protocol
evidence. createAgentSession is removed. retry rejects when the failure
leaves the backend outcome open, as the core contract requires, and the
literal state document a request sends is no longer published.
…ntract

The snapshot gains optional interrupts and subagents, and the session an
optional resume(responses) that answers pending interrupts by id. The fake
session publishes both fields and records resume calls.
Every published interrupt has an id, and resume takes the core contract's
responses in place of a bare value. One pending interrupt receives its
response's value; several are answered as one map keyed by backend id.
Callers in the cockpit examples, the native conversation example and the
parity fixtures move to the new command.
…he client only

The raw session has loaded nothing at that point, so its resume rejects for
a missing pause, not for the unmatched id. The session's own specs cover
the rejection; the diagnostic keeps the provider routing evidence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@blove
blove added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit f0bddd7 Nov 20, 2026
133 checks passed
@blove
blove deleted the blove/ag-ui-core-resume branch November 20, 2026 03:43
blove added a commit that referenced this pull request Nov 20, 2026
blove added a commit that referenced this pull request Nov 20, 2026
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