diff --git a/cockpit/ag-ui/subagents/react/src/children.ts b/cockpit/ag-ui/subagents/react/src/children.ts index 9a4e77113..e660cd401 100644 --- a/cockpit/ag-ui/subagents/react/src/children.ts +++ b/cockpit/ag-ui/subagents/react/src/children.ts @@ -50,14 +50,16 @@ export function observeChildren( const cards = new Map(previous.map((card) => [card.id, card])); let unsupported = false; try { + // Cards follow the current run; children of earlier runs are history. + const children = snapshot.subagents.filter((child) => !child.earlier); if ( cards.size !== previous.length || previous.length > 100 || - snapshot.subagents.length > 30 + children.length > 30 ) throw new Error(); const attributed = new Set( - snapshot.subagents.map((child) => child.started.subagentRunId) + children.map((child) => child.started.subagentRunId) ); if ( snapshot.transcript.some( @@ -68,7 +70,7 @@ export function observeChildren( ) throw new Error(); const seen = new Set(); - for (const child of snapshot.subagents) { + for (const child of children) { const started = child.started; const id = started.subagentRunId, callId = started.parentToolCallId; diff --git a/cockpit/ag-ui/subagents/react/src/policy.ts b/cockpit/ag-ui/subagents/react/src/policy.ts index 6abf36c79..95467c257 100644 --- a/cockpit/ag-ui/subagents/react/src/policy.ts +++ b/cockpit/ag-ui/subagents/react/src/policy.ts @@ -85,7 +85,7 @@ export function confirmParent( if (!valid()) return; const run = snapshot.run, transcript = snapshot.transcript, - children = snapshot.subagents; + children = snapshot.subagents.filter((child) => !child.earlier); if ( !valid() || snapshot.status !== 'idle' || diff --git a/libs/ag-ui/src/runtime/README.md b/libs/ag-ui/src/runtime/README.md index 96926b977..84ee317bd 100644 --- a/libs/ag-ui/src/runtime/README.md +++ b/libs/ag-ui/src/runtime/README.md @@ -149,16 +149,23 @@ const session = createSession({ threadId, url }); is sent. Each entry is the protocol's interrupt, so it has the core `id`, `reason`, `message` and `toolCallId` and any other field the backend sent. It is absent when nothing is waiting, and for a pause this session cannot answer. -- `subagents` lists the current run's children as core child agents: `id`, - `name`, `description`, `toolCallId`, `parentId`, `status`, and the child's own - `messages` and `toolCalls`, which the root lists do not repeat. The protocol - evidence stays on each child as `started` and `terminal`. A child with - finished evidence is `complete`, one with error evidence is `error` and - carries its message, and one with neither is `running` while the root run is - going and `unknown` after it. A child keeps its reference until its evidence, - status or records change. Children of earlier runs are bare evidence in - `earlierSubagents`. Records are matched by run id, so a later child that - reuses an id also lists the earlier child's records. +- `subagents` lists every child the session knows as a core child agent: + children of earlier root runs first, marked `earlier`, then the current run's, + each in start order. A child has `id`, `name`, `description`, `toolCallId`, + `parentId`, `status`, and its own `messages` and `toolCalls`, which the root + lists do not repeat. The protocol evidence stays on each child as `started` + and `terminal`. `earlierSubagents` still holds the earlier children's bare + evidence. + - Error evidence is `error` and carries its message. Finished evidence is + `complete`, unless the child finished `suspended`: it paused and can + continue, so it is `running` in its own run and while a later run is going, + and `unknown` once a later run ends without continuing it. A child with no + ending is `running` while the root run is going and `unknown` after it. + - A child lists the records attributed to its run id within its own run. A + child that starts again after pausing continues: it is one child, and keeps + the records from before the pause. Any other child that reuses a run id + replaces the earlier one and starts with none of its records. + - A child keeps its reference until its evidence, status or records change. - Every publication notifies subscribers, including one that changes only protocol evidence such as a decision or a child. - `submit` takes text, or `{ message, state? }` with a state patch. diff --git a/libs/ag-ui/src/runtime/agent-session.ts b/libs/ag-ui/src/runtime/agent-session.ts index 090f8fbbc..85280f524 100644 --- a/libs/ag-ui/src/runtime/agent-session.ts +++ b/libs/ag-ui/src/runtime/agent-session.ts @@ -33,9 +33,10 @@ export type SessionSnapshot = Omit< */ readonly interrupts?: readonly SessionInterrupt[]; /** - * The current root run's children, each with its own messages and tool - * calls and the protocol evidence it was read from. Children of earlier - * runs are in `earlierSubagents`. + * Every child agent the session knows, each with its own messages and + * tool calls and the protocol evidence it was read from: children of + * earlier root runs first, marked `earlier`, then the current run's. + * `earlierSubagents` still holds the earlier children's bare evidence. */ readonly subagents: readonly SessionSubagent[]; /** diff --git a/libs/ag-ui/src/runtime/child-projection.spec.ts b/libs/ag-ui/src/runtime/child-projection.spec.ts index 7b8d3e9d0..497e25c74 100644 --- a/libs/ag-ui/src/runtime/child-projection.spec.ts +++ b/libs/ag-ui/src/runtime/child-projection.spec.ts @@ -141,6 +141,102 @@ describe('core interrupts and child agents on the AG-UI snapshot', () => { } }); + it('keeps a paused child running and continues it with its records after resume', async () => { + const fixture = bindingFixture(); + try { + const run = fixture.session.submit('Book it'); + const exchange = await fixture.started(); + const paused = fixture.changed( + (snapshot) => snapshot.subagents[0]?.terminal !== undefined + ); + exchange.emit({ + type: 'SUBAGENT_STARTED', + subagentRunId: 'child', + name: 'booker', + }); + exchange.emit({ + type: 'TEXT_MESSAGE_START', + messageId: 'before', + role: 'assistant', + subagentRunId: 'child', + }); + exchange.emit({ + type: 'TEXT_MESSAGE_CONTENT', + messageId: 'before', + delta: 'Need approval', + }); + exchange.emit({ type: 'TEXT_MESSAGE_END', messageId: 'before' }); + exchange.emit({ + type: 'SUBAGENT_FINISHED', + subagentRunId: 'child', + outcome: { type: 'suspended', interruptIds: ['approval'] }, + }); + await paused; + exchange.emit({ + type: 'RUN_FINISHED', + threadId: exchange.body.threadId, + runId: exchange.body.runId, + outcome: { + type: 'interrupt', + interrupts: [{ id: 'approval', reason: 'approve' }], + }, + }); + await expect(run).resolves.toBe('paused'); + // Paused is not finished: the child can continue. + expect(fixture.session.getSnapshot().subagents[0].status).toBe('running'); + + const resumed = fixture.session.resume([ + { interruptId: 'approval', status: 'resolved' }, + ]); + const next = await fixture.started(1); + // Between the answer and the child's restart it is history, still going. + expect(fixture.session.getSnapshot().subagents).toMatchObject([ + { id: 'child', status: 'running', earlier: true }, + ]); + const continued = fixture.changed( + (snapshot) => + snapshot.subagents.length === 1 && + snapshot.subagents[0].messages.length === 2 + ); + next.emit({ + type: 'SUBAGENT_STARTED', + subagentRunId: 'child', + name: 'booker', + }); + next.emit({ + type: 'TEXT_MESSAGE_START', + messageId: 'after', + role: 'assistant', + subagentRunId: 'child', + }); + next.emit({ + type: 'TEXT_MESSAGE_CONTENT', + messageId: 'after', + delta: 'Booked', + }); + next.emit({ type: 'TEXT_MESSAGE_END', messageId: 'after' }); + // One child, not two, and it keeps what it said before the pause. + const child = (await continued).subagents[0]; + expect(child).not.toHaveProperty('earlier'); + expect(child.messages.map((message) => message.content)).toEqual([ + 'Need approval', + 'Booked', + ]); + next.emit({ type: 'SUBAGENT_FINISHED', subagentRunId: 'child' }); + next.emit({ + type: 'RUN_FINISHED', + threadId: next.body.threadId, + runId: next.body.runId, + }); + await expect(resumed).resolves.toBe('success'); + expect(fixture.session.getSnapshot().subagents[0].status).toBe( + 'complete' + ); + } finally { + await fixture.cleanup(); + } + }); + it('lists pending interrupts until an answer is sent, and answers them by id', async () => { const fixture = bindingFixture(); try { diff --git a/libs/ag-ui/src/runtime/child-projection.ts b/libs/ag-ui/src/runtime/child-projection.ts index e29b602e1..25a92f008 100644 --- a/libs/ag-ui/src/runtime/child-projection.ts +++ b/libs/ag-ui/src/runtime/child-projection.ts @@ -1,19 +1,27 @@ import type { AgentSubagent, Message, ToolCall } from '@threadplane/core'; import { projectMessages, projectToolCalls } from './message-projection.js'; import type { Observation } from './session-observation.js'; -import type { SubagentObservation } from './subagents.js'; +import { + currentFrom, + earlierSpan, + suspended, + type ChildSpan, + type SubagentObservation, +} from './subagents.js'; import type { Transcript } from './transcript.js'; type TranscriptRecord = Transcript[number]; /** - * One child of the current root run: the core child, with the protocol - * evidence it was read from. `messages` and `toolCalls` are the child's own - * and are not repeated in the root snapshot's. They are every transcript record - * attributed to the child's run id, so a later child that reuses an id also - * lists the earlier child's records. + * One child agent: the core child, with the protocol evidence it was read + * from. `messages` and `toolCalls` are the child's own and are not repeated in + * the root snapshot's. */ -export type SessionSubagent = AgentSubagent & SubagentObservation; +export type SessionSubagent = AgentSubagent & + SubagentObservation & { + /** Set on a child that settled in an earlier root run or came with the thread. */ + readonly earlier?: true; + }; /** A child's records read as a root transcript, so the root selectors apply. */ const unattributed = new WeakMap(); @@ -29,12 +37,23 @@ function asRoot(record: TranscriptRecord): TranscriptRecord { return known; } +/** + * - Error evidence is `error`, and finished evidence is `complete`, unless the + * child finished `suspended`: it paused and can continue, so it is `running` + * in its own run and while a later run is going, and `unknown` once a later + * run ends without continuing it. + * - A child with no ending is `running` while the root run is going and + * `unknown` after it. + */ function status( evidence: SubagentObservation, - running: boolean + running: boolean, + earlier: boolean ): AgentSubagent['status'] { - if (evidence.terminal) - return evidence.terminal.type === 'SUBAGENT_ERROR' ? 'error' : 'complete'; + const terminal = evidence.terminal; + if (terminal?.type === 'SUBAGENT_ERROR') return 'error'; + if (terminal && !suspended(evidence)) return 'complete'; + if (terminal) return running || !earlier ? 'running' : 'unknown'; return running ? 'running' : 'unknown'; } @@ -43,35 +62,57 @@ const noMessages: readonly Message[] = Object.freeze([]); const noCalls: readonly ToolCall[] = Object.freeze([]); /** - * The current run's children as core children. Each keeps its reference, and - * the list keeps its own, until that child's evidence, status or transcript - * changes. `previous` is the list this function returned last. + * Every child the session knows as a core child: those of earlier root runs + * first, then the current run's, each list in start order. A current child + * replaces an earlier one with the same run ID. + * + * A child lists the records attributed to its run ID within its own run. A + * child that starts again after pausing continues, and keeps the records from + * before the pause; any other child that reuses an ID starts with none. + * + * Each child keeps its reference, and the list keeps its own, until that + * child's evidence, status or records change. `previous` is the list this + * function returned last. */ export function projectSubagents( native: Observation, previous: readonly SessionSubagent[] = none ): readonly SessionSubagent[] { - if (!native.subagents.length) return previous.length ? none : previous; - const records = new Map(); - for (const record of native.transcript) { - const child = (record as { subagentRunId?: unknown }).subagentRunId; - if (typeof child !== 'string') continue; - const own = records.get(child); - if (own) own.push(asRoot(record)); - else records.set(child, [asRoot(record)]); - } - const prior = new Map(previous.map((child) => [child.id, child])); + const current = native.subagents; + const replaced = new Set(current.map((c) => c.started.subagentRunId)); + const earlier = (native.earlierSubagents ?? []).filter( + (child) => !replaced.has(child.started.subagentRunId) + ); + if (!current.length && !earlier.length) + return previous.length ? none : previous; const running = native.status === 'running'; - let changed = previous.length !== native.subagents.length; - const children = native.subagents.map((evidence, index) => { + const transcript = native.transcript; + const prior = new Map(previous.map((child) => [child.id, child])); + let changed = previous.length !== earlier.length + current.length; + const project = ( + evidence: SubagentObservation, + span: ChildSpan, + isEarlier: boolean, + index: number + ): SessionSubagent => { const { started, terminal } = evidence; const id = started.subagentRunId; + const records: TranscriptRecord[] = []; + const end = Math.min(span.to ?? transcript.length, transcript.length); + for (let position = span.from; position < end; position++) { + const record = transcript[position]; + if ((record as { subagentRunId?: unknown }).subagentRunId === id) + records.push(asRoot(record)); + } const before = prior.get(id); - const state = status(evidence, running); - // A child with terminal evidence streams nothing further. + const state = status(evidence, running, isEarlier); + // Only a child of the run that is going can still be streaming. const view = { - status: state === 'running' ? ('running' as const) : ('idle' as const), - transcript: Object.freeze(records.get(id) ?? []) as Transcript, + status: + state === 'running' && running && !terminal + ? ('running' as const) + : ('idle' as const), + transcript: Object.freeze(records) as Transcript, reasoningDurations: native.reasoningDurations, }; const messages = projectMessages(view, before?.messages ?? noMessages); @@ -81,6 +122,7 @@ export function projectSubagents( before.started === started && before.terminal === terminal && before.status === state && + before.earlier === (isEarlier || undefined) && before.messages === messages && before.toolCalls === toolCalls ) { @@ -107,7 +149,27 @@ export function projectSubagents( typeof terminal.message === 'string' && { error: terminal.message }), started, ...(terminal && { terminal }), + ...(isEarlier && { earlier: true as const }), }) as SessionSubagent; - }); + }; + const children = [ + ...earlier.map((child, index) => + project(child, earlierSpan(child), true, index) + ), + ...current.map((child, index) => + project( + child, + { + from: currentFrom( + child.started.subagentRunId, + current, + native.earlierSubagents + ), + }, + false, + earlier.length + index + ) + ), + ]; return changed ? Object.freeze(children) : previous; } diff --git a/libs/ag-ui/src/runtime/create-session.ts b/libs/ag-ui/src/runtime/create-session.ts index 5d40a174c..502238007 100644 --- a/libs/ag-ui/src/runtime/create-session.ts +++ b/libs/ag-ui/src/runtime/create-session.ts @@ -37,7 +37,7 @@ import { initialObservation, type Observation, } from './session-observation.js'; -import { earlierSubagents, type Subagents } from './subagents.js'; +import { nextInvocation, type Subagents } from './subagents.js'; import { createRun, httpFailure, type RunHandle } from './create-run.js'; import { createPublication } from './session-publication.js'; import { @@ -82,16 +82,20 @@ export interface SessionOptions readonly subagents?: Subagents; readonly interruptMode?: InterruptMode; } -/** A new root invocation observes no children yet; settled ones become history. */ -function nextInvocationSubagents(previous: Observation) { - const earlier = earlierSubagents( - previous.earlierSubagents, - previous.subagents +/** + * A new root invocation observes no children yet; settled ones become history. + * `transcript` is the history the new invocation begins with, when it is not + * the previous one. + */ +function nextInvocationSubagents( + previous: Observation, + transcript: Transcript = previous.transcript +) { + return nextInvocation( + previous, + previous.transcript.length, + transcript.length ); - return { - subagents: Object.freeze([]) as Subagents, - ...(earlier && { earlierSubagents: earlier }), - }; } export interface Session { /** The state declaration this session was created with, when it has one. */ @@ -673,7 +677,7 @@ export function createSession( status: 'running', transcript: last.transcript, state: last.state, - ...nextInvocationSubagents(previous), + ...nextInvocationSubagents(previous, last.transcript), run: Object.freeze({ id }), }), undefined, @@ -703,7 +707,9 @@ export function createSession( root(index) ); if (at < 0) - throw new Error('Regenerate needs the id of an assistant message.'); + throw new Error( + 'Regenerate needs the id of an assistant message.' + ); for (let index = at - 1; index >= 0 && prompt < 0; index--) if (transcript[index].role === 'user' && root(index)) prompt = index; @@ -728,7 +734,7 @@ export function createSession( ...previous, status: 'running', transcript, - ...nextInvocationSubagents(previous), + ...nextInvocationSubagents(previous, transcript), run: Object.freeze({ id }), }), signal, @@ -1492,8 +1498,7 @@ function createToolsOwner( resolve('aborted'); return; } - if (interruptMode !== 'native') - throw new TypeError(NOT_SETTLED); + if (interruptMode !== 'native') throw new TypeError(NOT_SETTLED); const previous = publication.getObservation(); captured = captureResponses(responses); claimDecision( diff --git a/libs/ag-ui/src/runtime/decision.type-test.ts b/libs/ag-ui/src/runtime/decision.type-test.ts index bfb4fdcfc..9845aa13e 100644 --- a/libs/ag-ui/src/runtime/decision.type-test.ts +++ b/libs/ag-ui/src/runtime/decision.type-test.ts @@ -99,3 +99,10 @@ void observer.resume?.([ ]); // @ts-expect-error the core contract has no pause token void observer.resume?.(pause, [resolved]); + +// Child agents of earlier root runs are marked, so a view can tell them apart. +const earlierChild: true | undefined = + session.getSnapshot().subagents[0]?.earlier; +// @ts-expect-error The mark is derived, not assigned. +session.getSnapshot().subagents[0].earlier = true; +void earlierChild; diff --git a/libs/ag-ui/src/runtime/session-http.spec.ts b/libs/ag-ui/src/runtime/session-http.spec.ts index ef29ccec0..f358c4746 100644 --- a/libs/ag-ui/src/runtime/session-http.spec.ts +++ b/libs/ag-ui/src/runtime/session-http.spec.ts @@ -319,8 +319,18 @@ describe('composed private session over held HTTP', () => { [...exchange.body.messages, ...next.body.messages].map((m) => m.id) ).size ).toBe(next.body.messages.length); - // The resumed invocation observes no children yet; the finished one is history. - expect(owner.getSnapshot().subagents).toEqual([]); + // The resumed invocation observes no children yet; the finished one is + // history, and still listed as a child agent with its own records. + const carried = owner.getSnapshot().subagents; + expect(carried).toHaveLength(1); + expect(carried[0]).toMatchObject({ + id: 'child', + status: 'complete', + earlier: true, + }); + expect(carried[0].messages).toEqual(settled.subagents[0].messages); + expect(carried[0].started).toBe(settled.subagents[0].started); + expect(settled.subagents[0]).not.toHaveProperty('earlier'); expect(settled).not.toHaveProperty('earlierSubagents'); expect(settled.subagents[0].terminal?.type).toBe('SUBAGENT_FINISHED'); // History keeps the child's protocol evidence, by reference, without @@ -361,17 +371,35 @@ describe('composed private session over held HTTP', () => { }, terminal: { type: 'SUBAGENT_FINISHED', subagentRunId: 'child' }, }; - // This turn asserts the child's identity and evidence, not its own - // messages and tool calls. + // The new child replaces the earlier one with its ID, and starts with + // none of that child's records. expect(latest).toHaveLength(1); - expect(latest).toMatchObject([ - { id: 'child', name: 'again', status: 'complete', ...reused }, + expect(latest).toStrictEqual([ + { + id: 'child', + name: 'again', + status: 'complete', + messages: [], + toolCalls: [], + ...reused, + }, ]); + expect(carried[0].messages).not.toEqual([]); expect(latest[0].started).toStrictEqual(reused.started); expect(latest[0].terminal).toStrictEqual(reused.terminal); const fourth = owner.submit('once more'); const last = await server.next(3); - expect(owner.getSnapshot().subagents).toEqual([]); + expect(owner.getSnapshot().subagents).toStrictEqual([ + { + id: 'child', + name: 'again', + status: 'complete', + messages: [], + toolCalls: [], + ...reused, + earlier: true, + }, + ]); expect(owner.getSnapshot().earlierSubagents).toStrictEqual([reused]); expect(owner.getSnapshot().earlierSubagents?.[0].started).toBe( latest[0].started diff --git a/libs/ag-ui/src/runtime/session-observation.ts b/libs/ag-ui/src/runtime/session-observation.ts index 5e6b216cc..11601a9e4 100644 --- a/libs/ag-ui/src/runtime/session-observation.ts +++ b/libs/ag-ui/src/runtime/session-observation.ts @@ -12,7 +12,11 @@ import type { PlainValue, } from '@threadplane/core'; import { ownTranscript, type Transcript } from './transcript.js'; -import { applySubagent, ownSubagents, type Subagents } from './subagents.js'; +import { + applySubagent, + restoredSubagents, + type Subagents, +} from './subagents.js'; import { NO_STATE, ownState, applyState } from './state.js'; import { reconcileTranscript } from './reconcile-transcript.js'; import { applyTextMessage } from './text-messages.js'; @@ -113,7 +117,7 @@ export function initialObservation( ): Observation { const transcript = ownTranscript(messages); assertTranscriptIdentity(transcript); - const earlier = ownSubagents(subagents); + const earlier = restoredSubagents(subagents, transcript.length); return Object.freeze({ status: 'idle', transcript, diff --git a/libs/ag-ui/src/runtime/subagents.ts b/libs/ag-ui/src/runtime/subagents.ts index 9993c3f00..9581466e3 100644 --- a/libs/ag-ui/src/runtime/subagents.ts +++ b/libs/ag-ui/src/runtime/subagents.ts @@ -32,6 +32,97 @@ export interface SubagentObservation { } export type Subagents = readonly SubagentObservation[]; +/** Where in the transcript a child's own records lie: from `from`, up to but + * not including `to`. A child of the current invocation has no `to`. */ +export interface ChildSpan { + readonly from: number; + readonly to?: number; +} +/** Bookkeeping beside the evidence, so the published evidence keeps its shape. */ +const invocationStarts = new WeakMap(); +const spans = new WeakMap(); + +/** True for a child whose last evidence says it paused and can continue. */ +export function suspended(child: SubagentObservation): boolean { + const terminal = child.terminal; + return ( + terminal?.type === 'SUBAGENT_FINISHED' && + (terminal.outcome as { type?: unknown } | undefined)?.type === 'suspended' + ); +} + +/** The transcript length when the invocation that owns `current` began. */ +export function invocationStart(current: Subagents): number { + return invocationStarts.get(current) ?? 0; +} + +/** + * The records an earlier child owns. Evidence restored with a thread owns the + * restored records attributed to it. + */ +export function earlierSpan(child: SubagentObservation): ChildSpan { + return spans.get(child) ?? { from: 0 }; +} + +/** + * Where a child of the current invocation begins. A child continues an earlier + * one with the same ID when that one paused, so it keeps those records; any + * other reuse of an ID starts a separate child. + */ +export function currentFrom( + id: string, + current: Subagents, + earlier: Subagents | undefined +): number { + const before = earlier?.find((child) => child.started.subagentRunId === id); + return before && suspended(before) + ? earlierSpan(before).from + : invocationStart(current); +} + +/** Restored evidence owns the restored transcript's records, and no later ones. */ +export function restoredSubagents( + restored: unknown, + transcriptLength: number +): Subagents | undefined { + const owned = ownSubagents(restored); + for (const child of owned ?? []) + spans.set(child, { from: 0, to: transcriptLength }); + return owned; +} + +/** + * Child evidence for the next root invocation. `ending` is the transcript + * length the ending invocation reached, and `start` the length the next one + * begins with; they differ when the next invocation rebuilds its history. + */ +export function nextInvocation( + previous: { + readonly subagents: Subagents; + readonly earlierSubagents?: Subagents; + }, + ending: number, + start: number +): { readonly subagents: Subagents; readonly earlierSubagents?: Subagents } { + for (const child of previous.subagents) + if (child.terminal) + spans.set(child, { + from: currentFrom( + child.started.subagentRunId, + previous.subagents, + previous.earlierSubagents + ), + to: ending, + }); + const earlier = earlierSubagents( + previous.earlierSubagents, + previous.subagents + ); + const subagents: Subagents = Object.freeze([]); + invocationStarts.set(subagents, start); + return { subagents, ...(earlier && { earlierSubagents: earlier }) }; +} + /** History for the next root invocation: earlier children, then this * invocation's children that have terminal evidence. A child with no terminal * evidence is dropped, because nothing later can establish what became of it. @@ -160,5 +251,7 @@ export function applySubagent( started: previous[index].started, terminal: captured, }); - return Object.freeze(next); + const applied: Subagents = Object.freeze(next); + invocationStarts.set(applied, invocationStart(previous)); + return applied; } diff --git a/libs/angular/src/observe-agent.ag-ui.spec.ts b/libs/angular/src/observe-agent.ag-ui.spec.ts index e85b62563..b6c498160 100644 --- a/libs/angular/src/observe-agent.ag-ui.spec.ts +++ b/libs/angular/src/observe-agent.ag-ui.spec.ts @@ -130,7 +130,8 @@ describe('observeAgent native AG-UI owner', () => { { id: 'child', name: 'worker', - status: 'complete', + // The child finished suspended: it paused and can continue. + status: 'running', messages: [], toolCalls: [], started: { diff --git a/libs/react/src/use-agent.ag-ui.spec.tsx b/libs/react/src/use-agent.ag-ui.spec.tsx index 660f10e0c..69591dc4e 100644 --- a/libs/react/src/use-agent.ag-ui.spec.tsx +++ b/libs/react/src/use-agent.ag-ui.spec.tsx @@ -120,7 +120,8 @@ describe('useAgent native AG-UI owner', () => { { id: 'child', name: 'worker', - status: 'complete', + // The child finished suspended: it paused and can continue. + status: 'running', messages: [], toolCalls: [], started: { diff --git a/scripts/react-parity/dispositions.json b/scripts/react-parity/dispositions.json index ed2e0e46a..8c3a82f29 100644 --- a/scripts/react-parity/dispositions.json +++ b/scripts/react-parity/dispositions.json @@ -19239,7 +19239,7 @@ "treatment": "internal", "status": "in-progress", "reason": "Private projection of the current run's child evidence into the core contract's child agents: each child's id, name, task, status and its own messages and tool calls, with the protocol evidence kept alongside.", - "note": "Covered by runtime specs over the real owner. Children of earlier runs stay bare evidence in earlierSubagents, and a child that reuses a run id also lists the earlier child's records." + "note": "Covered by runtime specs over the real owner. Children of earlier runs are listed first and marked earlier. A child that restarts after pausing continues with its records; any other reuse of a run id starts a separate child." }, { "id": "source:libs/ag-ui/src/runtime/message-projection.ts",