Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
50998de
feat(core): add typed application state to the session contract
blove Nov 18, 2026
bf1780d
feat(ag-ui): type the session's state and publish it in the core view
blove Nov 18, 2026
3894f08
feat(ag-ui): make the session a core AgentSession
blove Nov 18, 2026
016a123
test(ag-ui): expect core fields on the session snapshot in the packag…
blove Nov 18, 2026
72675d9
feat(core): add interrupts, resume and child agents to the session co…
blove Nov 19, 2026
d666233
feat(langgraph): answer interrupts by id through the core resume command
blove Nov 19, 2026
50984f8
test(native-conversation): send the unmatched-id diagnostic through t…
blove Nov 19, 2026
9812d7c
Merge remote-tracking branch 'origin/main' into blove/ag-ui-typed-ses…
blove Nov 19, 2026
84473df
Merge remote-tracking branch 'origin/main' into HEAD
blove Nov 19, 2026
f43223d
Merge remote-tracking branch 'origin/main' into blove/core-interrupts…
blove Nov 19, 2026
a73307f
Merge remote-tracking branch 'origin/main' into blove/core-interrupts…
blove Nov 19, 2026
a9376fc
Merge remote-tracking branch 'origin/main' into blove/core-interrupts…
blove Nov 19, 2026
ca50ac4
Merge the final head of #1658 into blove/ag-ui-session-is-agent-session
blove Nov 19, 2026
1e81b58
Merge the squash of #1658 into blove/ag-ui-session-is-agent-session (…
blove Nov 19, 2026
2d3100d
Merge remote-tracking branch 'origin/main' into blove/ag-ui-session-i…
blove Nov 19, 2026
ef1042c
Merge branch 'blove/core-interrupts-subagents' into blove/ag-ui-core-…
blove Nov 19, 2026
6815ffd
Merge remote-tracking branch 'origin/main' into HEAD
blove Nov 19, 2026
d31ac51
docs(ag-ui): the candidate emits the core session, not a view
blove Nov 19, 2026
1b4a8f8
feat(ag-ui): answer interrupts through the core resume command and pu…
blove Nov 19, 2026
f015faf
Merge the final head of #1659 into blove/ag-ui-core-resume
blove Nov 19, 2026
251be93
Merge the squash of #1659 into blove/ag-ui-core-resume (already merge…
blove Nov 19, 2026
51833c0
Merge remote-tracking branch 'origin/main' into blove/ag-ui-core-resume
blove Nov 19, 2026
0b3b702
test(parity): list the AG-UI child projection in the reviewed candida…
blove Nov 19, 2026
eb7dec8
test(cockpit): answer the Strands fixture's pauses through the core r…
blove Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cockpit/ag-ui/interrupts/react/src/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,11 @@ it.each(['approve', 'edit', 'cancel'] as const)(
action === 'edit' ? 20 : undefined
);
expect(session.resume).toHaveBeenCalledWith(
approval.pause,
[
{
interruptId: approval.interruptId,
status: 'resolved',
payload:
value:
action === 'cancel'
? { approved: false }
: action === 'edit'
Expand Down
9 changes: 7 additions & 2 deletions cockpit/ag-ui/interrupts/react/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,13 @@ export function createInterruptsApplication(options: {
: { approved: true };
if (selected.unsafe || !ownedValid()) return;
const pending = selected.session.resume(
approval.pause,
[{ interruptId: approval.interruptId, status: 'resolved', payload }],
[
{
interruptId: approval.interruptId,
status: 'resolved',
value: payload,
},
],
{ signal: admitted.signal }
);
void pending.catch(() => undefined);
Expand Down
8 changes: 6 additions & 2 deletions cockpit/ag-ui/interrupts/react/src/approval-policy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { Session, TextTranscriptRow } from '@threadplane/ag-ui';
import type {
DecisionState,
Session,
TextTranscriptRow,
} from '@threadplane/ag-ui';
export type NativeSnapshot = ReturnType<Session['getSnapshot']>;
export interface OwnedTurn {
readonly threadId: string;
Expand All @@ -9,7 +13,7 @@ export interface OwnedTurn {
export interface RefundApproval {
readonly threadId: string;
readonly sourceRunId: string;
readonly pause: Parameters<Session['resume']>[0];
readonly pause: Extract<DecisionState, { kind: 'native' }>['id'];
readonly interruptId: string;
readonly amount: number;
readonly customerId: string;
Expand Down
6 changes: 4 additions & 2 deletions cockpit/chat/debug/react/src/application.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AgentSnapshot, Message } from '@threadplane/core';
import type { AgentInterrupt, AgentSnapshot, Message } from '@threadplane/core';
import {
createMessageContent,
type MessageRow,
Expand Down Expand Up @@ -140,7 +140,9 @@ function captureNative(
toolCalls: captureData(
ownField(raw, 'toolCalls')
) as AgentSnapshot['toolCalls'],
interrupts: captureData(ownField(raw, 'interrupts')) as readonly unknown[],
interrupts: captureData(
ownField(raw, 'interrupts')
) as unknown as readonly AgentInterrupt[],
subgraphs: captureData(ownField(raw, 'subgraphs')) as readonly unknown[],
state: values.kind === 'available' ? values.values : undefined,
history,
Expand Down
2 changes: 1 addition & 1 deletion cockpit/chat/interrupts/react/src/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ it.each(['confirm', 'cancel'] as const)(
await h.app.submit('Forbidden while paused');
expect(h.session.resume).toHaveBeenCalledTimes(1);
expect(h.session.resume).toHaveBeenCalledWith(
value,
[{ interruptId: 'approval', status: 'resolved', value }],
expect.objectContaining({ signal: expect.any(AbortSignal) })
);
h.result();
Expand Down
25 changes: 22 additions & 3 deletions cockpit/chat/interrupts/react/src/application.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
AgentInterruptResponse,
AgentSession,
CompleteOutcome,
Message,
Expand All @@ -18,11 +19,12 @@ import {
type PauseAuthority,
} from './authority';

export interface InterruptsSession extends Omit<AgentSession, 'getSnapshot'> {
export interface InterruptsSession
extends Omit<AgentSession, 'getSnapshot' | 'resume'> {
getSnapshot(): InterruptsState;
load(options?: { readonly signal?: AbortSignal }): Promise<void>;
resume(
value: 'confirm' | 'cancel',
responses: readonly AgentInterruptResponse[],
options?: { readonly signal?: AbortSignal }
): Promise<CompleteOutcome>;
}
Expand Down Expand Up @@ -387,9 +389,26 @@ export function createInterruptsApplication(options: {
blocked();
return;
}
// A decision answers the one interrupt its authority was captured from.
const interruptId =
'text' in input ? undefined : dispatch.interrupts[0]?.id;
if (!('text' in input) && typeof interruptId !== 'string') {
selected.unsafe = true;
blocked();
return;
}
const outcome = await ('text' in input
? selected.session.submit(input.text, { signal: admitted.signal })
: selected.session.resume(input.value, { signal: admitted.signal }));
: selected.session.resume(
[
{
interruptId: interruptId as string,
status: 'resolved',
value: input.value,
},
],
{ signal: admitted.signal }
));
if (!valid()) return;
const live = read(selected, valid),
turn = selected.turn;
Expand Down
9 changes: 7 additions & 2 deletions cockpit/chat/interrupts/react/src/authority.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type { AgentSnapshot, Message, ToolCall } from '@threadplane/core';
import type {
AgentInterrupt,
AgentSnapshot,
Message,
ToolCall,
} from '@threadplane/core';

export interface InterruptsState extends AgentSnapshot {
readonly interrupts: readonly unknown[];
readonly interrupts: readonly AgentInterrupt[];
readonly subgraphs: readonly unknown[];
readonly history:
| readonly {
Expand Down
9 changes: 7 additions & 2 deletions cockpit/chat/subagents/react/src/authority.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type { AgentSnapshot, Message, ToolCall } from '@threadplane/core';
import type {
AgentInterrupt,
AgentSnapshot,
Message,
ToolCall,
} from '@threadplane/core';

export interface SubagentsState extends AgentSnapshot {
readonly interrupts: readonly unknown[];
readonly interrupts: readonly AgentInterrupt[];
readonly subgraphs: readonly unknown[];
readonly history:
| readonly {
Expand Down
4 changes: 2 additions & 2 deletions cockpit/chat/threads/react/src/authority.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AgentSnapshot, Message } from '@threadplane/core';
import type { AgentInterrupt, AgentSnapshot, Message } from '@threadplane/core';
export interface ThreadsState extends AgentSnapshot {
readonly interrupts: readonly unknown[];
readonly interrupts: readonly AgentInterrupt[];
readonly subgraphs: readonly unknown[];
readonly history:
| readonly {
Expand Down
9 changes: 7 additions & 2 deletions cockpit/chat/tool-calls/react/src/authority.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type { AgentSnapshot, Message, ToolCall } from '@threadplane/core';
import type {
AgentInterrupt,
AgentSnapshot,
Message,
ToolCall,
} from '@threadplane/core';

export interface ToolCallsState extends AgentSnapshot {
readonly interrupts: readonly unknown[];
readonly interrupts: readonly AgentInterrupt[];
readonly subgraphs: readonly unknown[];
readonly history:
| readonly {
Expand Down
17 changes: 12 additions & 5 deletions cockpit/deep-agents/filesystem/react/src/application.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
AgentInterruptResponse,
AgentSession,
AgentSnapshot,
CompleteOutcome,
Expand Down Expand Up @@ -37,11 +38,12 @@ import {
type FilesystemSnapshot,
type Turn,
} from './authority';
export interface FilesystemSession extends Omit<AgentSession, 'getSnapshot'> {
export interface FilesystemSession
extends Omit<AgentSession, 'getSnapshot' | 'resume'> {
getSnapshot(): AgentSnapshot & FilesystemSnapshot;
load(options?: { readonly signal?: AbortSignal }): Promise<void>;
resume(
value: PlainValue,
responses: readonly AgentInterruptResponse[],
options?: { readonly signal?: AbortSignal }
): Promise<CompleteOutcome>;
}
Expand Down Expand Up @@ -497,11 +499,16 @@ export function createFilesystemApplication(client: FilesystemClient) {
(snapshot as FilesystemApplicationSnapshot).phase !== 'confirming'
)
throw Error('Unavailable whole batch');
// The whole batch is one interrupt; its id names the response.
const interruptId = selected.session.getSnapshot().interrupts[0]?.id;
if (typeof interruptId !== 'string')
throw Error('Unavailable whole batch');
publish({ phase: 'working', approval: null, decisionToken: null });
if (!current(run)) return false;
outcome = await selected.session.resume(decision, {
signal: run.controller.signal,
});
outcome = await selected.session.resume(
[{ interruptId, status: 'resolved', value: decision }],
{ signal: run.controller.signal }
);
if (!current(run)) return false;
observe(run);
if (!current(run)) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ for (const consumed of [false, true]) {
const unsubscribe = session.subscribe(() => publications.push(session.getSnapshot()));
let rejected = false;
try {
await session.resume({ approved: false });
await session.resume([{ interruptId: session.getSnapshot().interrupts[0]?.id ?? 'consumed', status: 'resolved', value: { approved: false } }]);
} catch {
rejected = true;
} finally {
Expand All @@ -159,7 +159,7 @@ for (const consumed of [false, true]) {
expect(position((await api.threads.getState(threadId)).checkpoint)).toEqual(position(approved.checkpoint));
const stillPaused = await api.threads.getState(threadId, pausedPosition);
expect(stillPaused.tasks).toEqual([expect.objectContaining({ id: task.id, result: null, interrupts: task.interrupts })]);
expect(await session.resume({ approved: false })).toBe('success');
expect(await session.resume([{ interruptId: session.getSnapshot().interrupts[0].id, status: 'resolved', value: { approved: false } }])).toBe('success');
expect(transport.creations).toBe(beforeCreations + 1);
const exact = transport.finalPosition();
const rejected = await api.threads.getState(threadId, exact);
Expand Down
12 changes: 9 additions & 3 deletions cockpit/langgraph/interrupts/react/src/app.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function setup(
finish = resolve;
});
const batch = Object.freeze([{ id: 'refund', value: payload }]);
let interrupts: readonly { value: unknown }[] = batch;
let interrupts: readonly { id: string; value: unknown }[] = batch;
const session: InterruptSession = {
getSnapshot: () => ({
status: 'idle',
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('native React refund approval', () => {
await s.pause();
fireEvent.click(s.view.getByRole('button', { name: label }));
expect(s.session.resume).toHaveBeenCalledWith(
{ approved },
[{ interruptId: 'refund', status: 'resolved', value: { approved } }],
expect.any(Object)
);
expect(s.session.submit).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -185,7 +185,13 @@ describe('native React refund approval', () => {
s.view.getByRole('button', { name: 'Approve edited amount' })
);
expect(s.session.resume).toHaveBeenCalledWith(
{ approved: true, amount: 0 },
[
{
interruptId: 'refund',
status: 'resolved',
value: { approved: true, amount: 0 },
},
],
expect.any(Object)
);
});
Expand Down
30 changes: 19 additions & 11 deletions cockpit/langgraph/interrupts/react/src/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ function setup() {
const creation = deferred<string>();
const run = deferred<CompleteOutcome>();
const resumed = deferred<CompleteOutcome>();
let snapshot: AgentSnapshot & { interrupts: readonly { value?: unknown }[] } =
Object.freeze({
status: 'idle',
messages: [],
toolCalls: [],
interrupts: Object.freeze([]),
});
let snapshot: AgentSnapshot & {
interrupts: readonly { id: string; value?: unknown }[];
} = Object.freeze({
status: 'idle',
messages: [],
toolCalls: [],
interrupts: Object.freeze([]),
});
const observers = new Set<() => void>();
const release = vi.fn();
const session: InterruptSession = {
Expand Down Expand Up @@ -142,9 +143,10 @@ describe('public interrupts owner', () => {
await s.application.decide(required(decision), response);
await s.application.submit('Duplicate text');
expect(s.session.resume).toHaveBeenCalledTimes(1);
expect(s.session.resume).toHaveBeenCalledWith(response, {
signal: expect.any(AbortSignal),
});
expect(s.session.resume).toHaveBeenCalledWith(
[{ interruptId: 'reused-id', status: 'resolved', value: response }],
{ signal: expect.any(AbortSignal) }
);
expect(s.application.getSnapshot().busy).toBe(true);
expect(s.application.getSnapshot().decision).toBeNull();
expect(s.session.submit).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -244,7 +246,13 @@ describe('public interrupts owner', () => {
const pending = s.application.decide(required(decision), response);
response.amount = 100;
expect(s.session.resume).toHaveBeenCalledWith(
{ approved: true, amount: 25 },
[
{
interruptId: 'reused-id',
status: 'resolved',
value: { approved: true, amount: 25 },
},
],
expect.any(Object)
);
s.resumed.reject(new Error('PRIVATE credential'));
Expand Down
29 changes: 23 additions & 6 deletions cockpit/langgraph/interrupts/react/src/application.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
AgentInterruptResponse,
AgentSession,
AgentSnapshot,
CompleteOutcome,
Expand All @@ -8,12 +9,16 @@ import {
type MessageRow,
} from '@threadplane/content/messages';

export interface InterruptSession extends Omit<AgentSession, 'getSnapshot'> {
export interface InterruptSession
extends Omit<AgentSession, 'getSnapshot' | 'resume'> {
getSnapshot(): AgentSnapshot & {
readonly interrupts: readonly { readonly value?: unknown }[];
readonly interrupts: readonly {
readonly id: string;
readonly value?: unknown;
}[];
};
resume(
value: RefundResponse,
responses: readonly AgentInterruptResponse[],
options?: { readonly signal?: AbortSignal }
): Promise<CompleteOutcome>;
}
Expand Down Expand Up @@ -112,6 +117,8 @@ export function createInterruptsApplication(options: {
let capturedBatch:
| ReturnType<InterruptSession['getSnapshot']>['interrupts']
| undefined;
/** The id of the one interrupt behind the projected decision. */
let capturedId: string | undefined;
let operation: AbortController | undefined;
let disposed = false;
let disposal: Promise<void> | undefined;
Expand All @@ -126,8 +133,13 @@ export function createInterruptsApplication(options: {
if (interrupts === capturedBatch) return;
capturedBatch = interrupts;
const root =
interrupts.length === 1 ? ownData(interrupts[0], ['value']) : undefined;
const refund = root && refundPayload(root['value']);
interrupts.length === 1
? ownData(interrupts[0], ['id', 'value'])
: undefined;
const id = root?.['id'];
const refund =
root && typeof id === 'string' ? refundPayload(root['value']) : undefined;
capturedId = refund && typeof id === 'string' ? id : undefined;
publish({
decision: refund ? Object.freeze({ refund }) : null,
canSubmit: false,
Expand Down Expand Up @@ -234,12 +246,17 @@ export function createInterruptsApplication(options: {
)
return;
const admittedBatch = capturedBatch;
const interruptId = capturedId;
if (interruptId === undefined) return;
await perform('decision', (owned, signal) => {
// Publishing pending state can synchronously replace the observed batch.
// Reproject that pause without dispatching the superseded decision.
if (owned.getSnapshot().interrupts !== admittedBatch)
return Promise.resolve('paused');
return owned.resume(captured, { signal });
return owned.resume(
[{ interruptId, status: 'resolved', value: captured }],
{ signal }
);
});
}
async function stop() {
Expand Down
Loading
Loading