diff --git a/libs/langgraph/src/runtime/README.md b/libs/langgraph/src/runtime/README.md index 2ff51505c..4f8c834c6 100644 --- a/libs/langgraph/src/runtime/README.md +++ b/libs/langgraph/src/runtime/README.md @@ -317,15 +317,15 @@ panel or telemetry: `getSnapshot()` returns a frozen `LangGraphLifecycle` and `useSyncExternalStore`. Each value is epoch milliseconds on this clock, null until its milestone happens. -| Value | Stamped | -| --------------------- | -------------------------------------------------------------- | -| `streamStartedAt` | The first event to arrive on any run's stream. | -| `streamErrorAt` | The most recent published failure, as `{ at, kind }`. | -| `interruptReceivedAt` | The first time the session held a pending interrupt. | -| `interruptResolvedAt` | The most recent `resume` the session accepted. | -| `threadPersistedAt` | The first history read that returned saved checkpoints. | -| `toolCallStartedAt` | The first time the session held a tool call. | -| `toolCallCompletedAt` | The first time a tool call was complete or failed. | +| Value | Stamped | +| --------------------- | ------------------------------------------------------- | +| `streamStartedAt` | The first event to arrive on any run's stream. | +| `streamErrorAt` | The most recent published failure, as `{ at, kind }`. | +| `interruptReceivedAt` | The first time the session held a pending interrupt. | +| `interruptResolvedAt` | The most recent `resume` the session accepted. | +| `threadPersistedAt` | The first history read that returned saved checkpoints. | +| `toolCallStartedAt` | The first time the session held a tool call. | +| `toolCallCompletedAt` | The first time a tool call was complete or failed. | A session serves one thread, so nothing is reset: where the Angular adapter clears its `AgentLifecycle` on `switchThread()`, a session for another thread @@ -365,6 +365,32 @@ paused. The preflight detects already-observed consumption, but it is not an ato server claim. Applications must coordinate responders to the same task. Distinct checkpoint branches do not provide independent opposing decisions on one task. +## Child agents + +`snapshot.subgraphs` holds one entry for each child graph the run reported, with +its `namespace`, its own `messages` and `toolCalls`, its `state`, `interrupts` +and `error`. `snapshot.subagents` publishes the same children as the core +contract's child agents, one for each and in the same order, so a component +written for core sessions can show them: + +- `id` is the namespace path as JSON, which stays unique whatever a segment + contains. `parentId` is the `id` of the enclosing child graph, and is absent + for a child of the root graph. `namespace` is kept alongside. +- `name` is the node that started the child: the part of the last namespace + segment before its `:`. +- `messages` and `toolCalls` are the child graph's own, the same references as + in `subgraphs`. The root `messages` and `toolCalls` do not repeat them. +- `status` is `error` for a child that failed, with the display text in + `error`, and `running` while the root run is going. After the run, a child + whose last message succeeded is `complete`, one a pause stopped is still + `running` because a resume continues it, and any other child is `unknown`. +- LangGraph does not relate a child graph to a tool call, so `toolCallId` and + `description` are never set. + +A child agent keeps its reference while its child graph and status are +unchanged. Child agents give no command authority: answering a pause is the +root session's `resume`. + ## Thread directory `createLangGraphThreadDirectory` in `thread-directory.ts` implements the diff --git a/libs/langgraph/src/runtime/langgraph-snapshot.ts b/libs/langgraph/src/runtime/langgraph-snapshot.ts index 1393ead24..04442086d 100644 --- a/libs/langgraph/src/runtime/langgraph-snapshot.ts +++ b/libs/langgraph/src/runtime/langgraph-snapshot.ts @@ -5,8 +5,10 @@ import type { DeepReadonly, PlainValue, Message, + ToolCall, ToolContract, } from '@threadplane/core'; +import type { LangGraphSubagent } from './subagent-projection.js'; import type { Interrupt, ThreadState } from '@langchain/langgraph-sdk'; /** Compact metadata from an explicitly loaded page, without repeated state data. */ @@ -39,12 +41,17 @@ export type LangGraphSnapshotState = unknown extends TState export interface LangGraphSubgraph { readonly namespace: readonly string[]; readonly messages: readonly Message[]; + /** The child graph's own tool calls, referenced by `Message.toolCallIds` in `messages`. */ + readonly toolCalls: readonly ToolCall[]; /** A child graph's state. It is never checked against the session's declaration. */ readonly state: LangGraphState | undefined; readonly interrupts: readonly LangGraphWireInterrupt[]; readonly error?: AgentError; } +/** What a publication supplies: the session derives `subagents` from `subgraphs`. */ +export type LangGraphPublication = Omit; + /** Backend-private extension; the core snapshot remains backend-independent. */ export type LangGraphSnapshot< TTools extends { [K in keyof TTools]: ToolContract } = Record< @@ -52,7 +59,7 @@ export type LangGraphSnapshot< ToolContract >, TState = unknown -> = Omit, 'interrupts'> & { +> = Omit, 'interrupts' | 'subagents'> & { /** Last explicit history page; undefined until loaded. Not a live branch tree. */ readonly history: readonly LangGraphHistoryEntry[] | undefined; /** @@ -68,4 +75,9 @@ export type LangGraphSnapshot< readonly reconnect?: { readonly runId: string }; readonly interrupts: readonly LangGraphInterrupt[]; readonly subgraphs: readonly LangGraphSubgraph[]; + /** + * The child graphs in `subgraphs` as the core contract's child agents, one + * for each and in the same order. + */ + readonly subagents: readonly LangGraphSubagent[]; }; diff --git a/libs/langgraph/src/runtime/ownership.ts b/libs/langgraph/src/runtime/ownership.ts index 6a6dabf7d..f44f750a5 100644 --- a/libs/langgraph/src/runtime/ownership.ts +++ b/libs/langgraph/src/runtime/ownership.ts @@ -10,11 +10,13 @@ import { } from '@threadplane/core'; import type { LangGraphInterrupt, + LangGraphPublication, LangGraphWireInterrupt, LangGraphSnapshot, LangGraphSubgraph, LangGraphState, } from './langgraph-snapshot.js'; +import { projectSubagents } from './subagent-projection.js'; // Only objects projected here are trusted. Object.isFrozen on external input is // insufficient: its children may still be mutable. The weak set retains no data. @@ -324,7 +326,7 @@ export function ownSnapshot( /** One backend aggregate, composing the core fields and owned application data. */ export function ownLangGraphSnapshot( - input: LangGraphSnapshot, + input: LangGraphPublication, previous?: LangGraphSnapshot ): LangGraphSnapshot { const core = ownSnapshot(input, previous); @@ -333,6 +335,12 @@ export function ownLangGraphSnapshot( previous?.history as PlainValue ) as LangGraphSnapshot['history']; const subgraphs = ownSubgraphs(input.subgraphs, previous?.subgraphs); + // Derived here, so the children always agree with the published child graphs. + const subagents = projectSubagents( + subgraphs, + core.status, + previous?.subagents + ); const state = ownValueWithSharing(input.state, previous?.state) as | LangGraphState | undefined; @@ -355,6 +363,7 @@ export function ownLangGraphSnapshot( stateIssues === previous?.stateIssues && interrupts === previous?.interrupts && subgraphs === previous?.subgraphs && + subagents === previous?.subagents && reconnect === previous?.reconnect ) return previous; @@ -371,6 +380,7 @@ export function ownLangGraphSnapshot( ...(stateIssues ? { stateIssues } : {}), interrupts, subgraphs, + subagents, ...(reconnect ? { reconnect } : {}), }); } @@ -390,6 +400,13 @@ export function ownSubgraph( ownMessage, sameMessage ); + // A restored child graph may predate `toolCalls`. + const toolCalls = ownArray( + input.toolCalls ?? [], + previous?.toolCalls, + ownToolCall, + sameToolCall + ); const state = ownValueWithSharing(input.state, previous?.state) as | LangGraphState | undefined; @@ -404,6 +421,7 @@ export function ownSubgraph( previous && namespace === previous.namespace && messages === previous.messages && + toolCalls === previous.toolCalls && state === previous.state && interrupts === previous.interrupts && error === previous.error @@ -412,6 +430,7 @@ export function ownSubgraph( return freeze({ namespace, messages, + toolCalls, state, interrupts, ...(error ? { error } : {}), @@ -430,6 +449,7 @@ export function ownSubgraphs( a === b || (a.namespace === b.namespace && a.messages === b.messages && + a.toolCalls === b.toolCalls && a.state === b.state && a.interrupts === b.interrupts && sameError(a.error, b.error)) diff --git a/libs/langgraph/src/runtime/publication.spec.ts b/libs/langgraph/src/runtime/publication.spec.ts index 7595663ac..eadd9d6e1 100644 --- a/libs/langgraph/src/runtime/publication.spec.ts +++ b/libs/langgraph/src/runtime/publication.spec.ts @@ -2,9 +2,9 @@ import { streamingDelivery } from '@threadplane/core'; import { describe, expect, it } from 'vitest'; import { createPublication } from './publication'; import { deferred } from './testing/deferred'; -import type { LangGraphSnapshot } from './langgraph-snapshot'; +import type { LangGraphPublication } from './langgraph-snapshot'; -function snapshot(content = 'one'): LangGraphSnapshot { +function snapshot(content = 'one'): LangGraphPublication { return { status: 'idle', history: undefined, @@ -36,7 +36,7 @@ describe('private snapshot publication', () => { it('publishes reasoning-only changes, owns queued getter strings and suppresses equal values', () => { const publication = createPublication(snapshot()); let reasoning = 'Captured'; - const input = (): LangGraphSnapshot => ({ + const input = (): LangGraphPublication => ({ ...snapshot(), messages: [ { @@ -47,7 +47,7 @@ describe('private snapshot publication', () => { }, ], }); - const seen: LangGraphSnapshot[] = []; + const seen: LangGraphPublication[] = []; publication.subscribe(() => { seen.push(publication.getSnapshot()); if (seen.length === 1) { @@ -78,11 +78,11 @@ describe('private snapshot publication', () => { const citations = [ { id: 'c', index: 1, title: 'Original', extra: { tags: ['original'] } }, ]; - const input = (): LangGraphSnapshot => ({ + const input = (): LangGraphPublication => ({ ...snapshot('two'), messages: [{ ...snapshot('two').messages[0], citations }], }); - const seen: LangGraphSnapshot[] = []; + const seen: LangGraphPublication[] = []; publication.subscribe(() => { seen.push(publication.getSnapshot()); if (seen.length === 1) { @@ -138,7 +138,7 @@ describe('private snapshot publication', () => { if (populated) array[0] = 1; return array; }; - const input = (length: number): LangGraphSnapshot => ({ + const input = (length: number): LangGraphPublication => ({ ...snapshot(), toolCalls: [ { @@ -230,7 +230,7 @@ describe('private snapshot publication', () => { ...snapshot('Invalid'), state: { count: 9 }, interrupts: [{ value: new Date() }], - } as unknown as LangGraphSnapshot) + } as unknown as LangGraphPublication) ).toThrow(TypeError); expect(publication.getSnapshot()).toBe(before); }); @@ -241,7 +241,7 @@ describe('private snapshot publication', () => { publication.publish({ ...snapshot('candidate'), state: { bad: new Date(0) }, - } as unknown as LangGraphSnapshot) + } as unknown as LangGraphPublication) ).toThrow(TypeError); expect(publication.getSnapshot()).toBe(before); }); @@ -249,12 +249,12 @@ describe('private snapshot publication', () => { it('owns application values and suppresses equal queued aggregate publications', () => { const data = { stable: { x: 1 }, count: 1 }; const publication = createPublication({ ...snapshot(), state: data }); - const first = publication.getSnapshot() as LangGraphSnapshot; + const first = publication.getSnapshot() as LangGraphPublication; expect(first.state).toEqual(data); expect(first.state).not.toBe(data); data.stable.x = 9; expect(first.state?.['stable']).toEqual({ x: 1 }); - const seen: LangGraphSnapshot[] = []; + const seen: LangGraphPublication[] = []; for (let index = 0; index < 2; index++) publication.subscribe(() => { if (publication.getSnapshot().status === 'running') { @@ -268,7 +268,7 @@ describe('private snapshot publication', () => { } }); publication.subscribe(() => - seen.push(publication.getSnapshot() as LangGraphSnapshot) + seen.push(publication.getSnapshot() as LangGraphPublication) ); publication.publish({ ...first, status: 'running' }); expect(seen).toHaveLength(2); @@ -288,7 +288,7 @@ describe('private snapshot publication', () => { toolCalls: [{ ...input.toolCalls[0], args: new Date() }], }; expect(() => - createPublication(invalid as unknown as LangGraphSnapshot) + createPublication(invalid as unknown as LangGraphPublication) ).toThrow(TypeError); const publication = createPublication({ ...input, @@ -300,7 +300,7 @@ describe('private snapshot publication', () => { toolCalls: [ { id: 't', name: 'search', status: 'running', args: new Date() }, ], - } as unknown as LangGraphSnapshot) + } as unknown as LangGraphPublication) ).toThrow(TypeError); }); it('caches repeated reads per session and observes only actual changes', () => { diff --git a/libs/langgraph/src/runtime/publication.ts b/libs/langgraph/src/runtime/publication.ts index a1ad40a82..d40e34936 100644 --- a/libs/langgraph/src/runtime/publication.ts +++ b/libs/langgraph/src/runtime/publication.ts @@ -1,12 +1,12 @@ import type { AgentSessionCustomEvent } from '@threadplane/core'; -import type { LangGraphSnapshot } from './langgraph-snapshot.js'; +import type { LangGraphPublication } from './langgraph-snapshot.js'; import { ownLangGraphSnapshot } from './ownership.js'; /** Backend-private publication. Listener failures are reported once to the * optional callback and otherwise ignored; reporter failures are contained too. * Neither kind of failure changes execution state or rejects a command. */ export function createPublication( - initial: LangGraphSnapshot, + initial: LangGraphPublication, reportListenerError: (error: unknown) => void = () => undefined ) { let current = ownLangGraphSnapshot(initial); @@ -36,7 +36,7 @@ export function createPublication( } } - function publish(input: LangGraphSnapshot): void { + function publish(input: LangGraphPublication): void { // Capture external ingress now, including when a listener queues a publish. const captured = ownLangGraphSnapshot(input, current); schedule(() => { diff --git a/libs/langgraph/src/runtime/session-lifecycle.spec.ts b/libs/langgraph/src/runtime/session-lifecycle.spec.ts index 28ba2fb3f..08045e632 100644 --- a/libs/langgraph/src/runtime/session-lifecycle.spec.ts +++ b/libs/langgraph/src/runtime/session-lifecycle.spec.ts @@ -77,6 +77,7 @@ describe('neutral session ownership', () => { state: undefined, interrupts: [], subgraphs: [], + subagents: [], }); expect(first).not.toHaveBeenCalled(); expect(a.stream).not.toHaveBeenCalled(); diff --git a/libs/langgraph/src/runtime/subagent-projection.ts b/libs/langgraph/src/runtime/subagent-projection.ts new file mode 100644 index 000000000..2eddefe70 --- /dev/null +++ b/libs/langgraph/src/runtime/subagent-projection.ts @@ -0,0 +1,86 @@ +import type { AgentStatus, AgentSubagent } from '@threadplane/core'; +import type { LangGraphSubgraph } from './langgraph-snapshot.js'; + +/** + * A child graph as a core child agent. `id` is the child's namespace path as + * JSON, which stays unique whatever a segment contains, and `name` is the node + * that started it. LangGraph does not + * relate a child graph to a tool call, so `toolCallId` and `description` are + * never set. + */ +export type LangGraphSubagent = AgentSubagent & { + /** The child graph's full namespace path, as in `subgraphs`. */ + readonly namespace: readonly string[]; +}; + +/** A namespace segment is `node:task`; a node name may itself hold no colon. */ +function nodeOf(segment: string): string { + const at = segment.indexOf(':'); + return at < 0 ? segment : segment.slice(0, at); +} + +/** + * - A child that failed is `error`. + * - While the root run is going, a child is `running`. + * - After it, the child's last message decides: a successful one is + * `complete`, and one a pause stopped is still `running`, because a resume + * continues it. Anything else, and a child with no messages, is `unknown`. + */ +function statusOf( + child: LangGraphSubgraph, + running: boolean +): AgentSubagent['status'] { + if (child.error) return 'error'; + if (running) return 'running'; + const last = child.messages.at(-1)?.delivery; + if (last?.phase !== 'complete') return 'unknown'; + if (last.outcome === 'success') return 'complete'; + return last.outcome === 'paused' ? 'running' : 'unknown'; +} + +const projected = new WeakMap< + LangGraphSubgraph, + Partial> +>(); +const none: readonly LangGraphSubagent[] = Object.freeze([]); + +/** + * The session's child graphs as core child agents, in the order they were + * first observed. A child keeps its reference while its child graph and status + * are unchanged, and the list keeps its own while every child does. + */ +export function projectSubagents( + subgraphs: readonly LangGraphSubgraph[], + status: AgentStatus, + previous: readonly LangGraphSubagent[] = none +): readonly LangGraphSubagent[] { + if (!subgraphs.length) return previous.length ? none : previous; + const running = status === 'running'; + let changed = previous.length !== subgraphs.length; + const children = subgraphs.map((child, index) => { + const state = statusOf(child, running); + let known = projected.get(child); + if (!known) projected.set(child, (known = {})); + let subagent = known[state]; + if (!subagent) { + const { namespace } = child; + const message = child.error?.message; + subagent = Object.freeze({ + id: JSON.stringify(namespace), + name: nodeOf(namespace[namespace.length - 1] ?? ''), + ...(namespace.length > 1 && { + parentId: JSON.stringify(namespace.slice(0, -1)), + }), + status: state, + messages: child.messages, + toolCalls: child.toolCalls, + ...(state === 'error' && message && { error: message }), + namespace, + }); + known[state] = subagent; + } + if (previous[index] !== subagent) changed = true; + return subagent; + }); + return changed ? Object.freeze(children) : previous; +} diff --git a/libs/langgraph/src/runtime/subgraph-projection.ts b/libs/langgraph/src/runtime/subgraph-projection.ts index 215b02ce8..2ac8a0fbd 100644 --- a/libs/langgraph/src/runtime/subgraph-projection.ts +++ b/libs/langgraph/src/runtime/subgraph-projection.ts @@ -95,7 +95,7 @@ function replace( previous: SubgraphObservation, namespace: readonly string[], child: ChildProjection, - entry: LangGraphSubgraph + entry: Omit ): SubgraphObservation { const key = JSON.stringify(namespace); const active = new Map(previous.active); @@ -104,7 +104,11 @@ function replace( (value) => JSON.stringify(value.namespace) === key ); const entries = [...previous.subgraphs]; - const projected = ownSubgraph(entry, previous.subgraphs[index]); + // The child's reducer state is the one source of its tool calls. + const projected = ownSubgraph( + { ...entry, toolCalls: child.state.toolCalls }, + previous.subgraphs[index] + ); if (index < 0) entries.push(projected); else entries[index] = projected; return { active, subgraphs: ownSubgraphs(entries, previous.subgraphs) }; diff --git a/libs/langgraph/src/runtime/subgraphs.spec.ts b/libs/langgraph/src/runtime/subgraphs.spec.ts index e8fab8c93..992fbddc7 100644 --- a/libs/langgraph/src/runtime/subgraphs.spec.ts +++ b/libs/langgraph/src/runtime/subgraphs.spec.ts @@ -1,5 +1,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest'; import type { ThreadState } from '@langchain/langgraph-sdk'; +import type { AgentSession } from '@threadplane/core'; import { createSession } from './create-session'; import type { AgentTransport, StreamEvent } from './transport.types'; import { controlledTransport } from './testing/controlled-transport'; @@ -76,6 +77,82 @@ afterEach(async () => { await Promise.all(cleanups.splice(0).map((cleanup) => cleanup())); }); +describe('child graphs as core child agents', () => { + it('publishes one child agent for each child graph, with its own transcript', async () => { + const f = fixture(); + expect(f.session.getSnapshot().subagents).toEqual([]); + const run = f.session.submit('Go'); + await f.started(); + await f.emit(child('Found it', ['research:1'])); + await f.emit(child('Nested', ['research:1', 'tools:2'])); + const running = f.session.getSnapshot(); + expect(running.subagents).toHaveLength(2); + const [research, nested] = running.subagents; + expect(research).toMatchObject({ + id: '["research:1"]', + name: 'research', + status: 'running', + namespace: ['research:1'], + toolCalls: [], + }); + expect('parentId' in research).toBe(false); + expect(nested).toMatchObject({ + id: '["research:1","tools:2"]', + name: 'tools', + parentId: research.id, + status: 'running', + }); + // The child agent and the child graph share one transcript. + expect(research.messages).toBe(running.subgraphs[0].messages); + expect(research.messages[0].content).toBe('Found it'); + // The root transcript does not repeat a child's messages. + expect(running.messages.map((message) => message.content)).toEqual(['Go']); + + // A change to one child leaves the other child agent's reference alone. + await f.emit(child(' again', ['research:1', 'tools:2'])); + const next = f.session.getSnapshot(); + expect(next.subagents[0]).toBe(research); + expect(next.subagents[1]).not.toBe(nested); + // A root-only event keeps the whole list. + await f.emit({ ...child('Root'), namespace: undefined }); + expect(f.session.getSnapshot().subagents).toBe(next.subagents); + + await f.emit(full('Root answer')); + f.streams[0].finish(); + expect(await run).toBe('success'); + const settled = f.session.getSnapshot(); + expect(settled.subagents.map((entry) => entry.status)).toEqual([ + 'complete', + 'complete', + ]); + // A core observer reads the same children. + const observer: AgentSession = f.session; + expect(observer.getSnapshot().subagents?.[0]?.id).toBe('["research:1"]'); + }); + + it('reports a failed child as error and an aborted one as unknown', async () => { + const f = fixture(); + const run = f.session.submit('Go'); + await f.started(); + await f.emit(child('Working', ['ok:1'])); + await f.emit(child('Working', ['bad:2'])); + await f.emit({ + type: 'error', + namespace: ['bad:2'], + data: { error: 'Boom', message: 'The search failed' }, + }); + const failed = f.session.getSnapshot().subagents[1]; + expect(failed.status).toBe('error'); + expect(typeof failed.error).toBe('string'); + expect(f.session.getSnapshot().subagents[0].status).toBe('running'); + await f.session.stop(); + expect(await run).toBe('aborted'); + expect( + f.session.getSnapshot().subagents.map((entry) => entry.status) + ).toEqual(['unknown', 'error']); + }); +}); + describe('private subgraph observations', () => { it('preserves custom root error wrapper fields when capturing event routing', async () => { const session = createSession({ @@ -196,6 +273,18 @@ describe('private subgraph observations', () => { recovery: 'none', }); expect(JSON.stringify(snapshot)).not.toContain('SECRET'); + // The child's call is the child's own: listed with it, not at the root. + expect(snapshot.subgraphs[0].toolCalls.map((call) => call.id)).toEqual([ + 'child-tool', + ]); + expect(snapshot.subagents[0].toolCalls).toBe( + snapshot.subgraphs[0].toolCalls + ); + expect(snapshot.subagents[0].messages[0].toolCallIds).toEqual([ + 'child-tool', + ]); + expect(snapshot.subagents[0]).toMatchObject({ status: 'error' }); + expect(snapshot.subagents[0].error).not.toContain('SECRET'); expect(snapshot.subgraphs[0].messages[0].delivery).toMatchObject({ outcome: 'error', }); diff --git a/libs/langgraph/src/runtime/subgraphs.type-test.ts b/libs/langgraph/src/runtime/subgraphs.type-test.ts index fd962061f..57b6f10e3 100644 --- a/libs/langgraph/src/runtime/subgraphs.type-test.ts +++ b/libs/langgraph/src/runtime/subgraphs.type-test.ts @@ -1,6 +1,13 @@ -import type { AgentSession, Message, PlainValue } from '@threadplane/core'; +import type { + AgentSession, + AgentSubagent, + Message, + PlainValue, + ToolCall, +} from '@threadplane/core'; import { createSession } from './create-session'; import type { LangGraphSubgraph } from './langgraph-snapshot'; +import type { LangGraphSubagent } from './subagent-projection'; const session = createSession({ assistantId: 'a', threadId: 't', @@ -20,6 +27,18 @@ const snapshot = session.getSnapshot(); const children: readonly LangGraphSubgraph[] = snapshot.subgraphs; const messages: readonly Message[] = children[0].messages; const payload: PlainValue = children[0].state?.['any']; +// Child graphs are also published as the core contract's child agents. +const agents: readonly LangGraphSubagent[] = snapshot.subagents; +const coreAgents: readonly AgentSubagent[] | undefined = + observer.getSnapshot().subagents; +const agentCalls: readonly ToolCall[] = agents[0].toolCalls; +const childCalls: readonly ToolCall[] = children[0].toolCalls; +const path: readonly string[] = agents[0].namespace; +// @ts-expect-error The child agents are derived, not assigned. +snapshot.subagents = []; +// @ts-expect-error A child agent exposes no commands. +agents[0].resume([]); +void [coreAgents, agentCalls, childCalls, path]; // @ts-expect-error Observation collection is readonly. snapshot.subgraphs = []; // @ts-expect-error Observation arrays are readonly. diff --git a/scripts/react-parity/dispositions.json b/scripts/react-parity/dispositions.json index ed2e0e46a..96104edda 100644 --- a/scripts/react-parity/dispositions.json +++ b/scripts/react-parity/dispositions.json @@ -12767,6 +12767,17 @@ "reason": "Private staged LangGraph runtime subset; fixture-only and not a neutral public LangGraph root or tarball.", "note": "Resume projection preserves unchanged baseline delivery, attributes current same-ID activity, and limits finalized tool eligibility to the resumed turn across stream batches and follow-ups. Live pause delivery still uses the shared root interrupt batch. Broader T09 migration remains open." }, + { + "id": "source:libs/langgraph/src/runtime/subagent-projection.ts", + "taskIds": [ + "T09", + "T10" + ], + "treatment": "internal", + "status": "in-progress", + "reason": "Private projection of the session's child graphs into the core contract's child agents: an id, the starting node's name, a status and the child's own messages and tool calls.", + "note": "Covered by runtime specs. LangGraph does not relate a child graph to a tool call, so toolCallId and description are never set." + }, { "id": "source:libs/langgraph/src/runtime/subgraph-projection.ts", "taskIds": [ @@ -19227,7 +19238,7 @@ "treatment": "internal", "status": "in-progress", "reason": "Private core AgentSession view of the native owner: a snapshot derived from the native one with the message and tool-call selectors, change-only notification, a display error for a failed run, and text submit, stop and dispose forwarded to the owner.", - "note": "Covered by runtime specs and a React Chat integration spec over the real owner. Exported from the test-only candidate package entry and checked from installed tarballs; not exported from the published package root. A rejected credential (401 or 403) is an auth error and another HTTP status is carried on a server error. State patches, native resume, client-tool evidence, a status check and a failure without a response are not represented." + "note": "Covered by runtime specs and a React Chat integration spec over the real owner. Exported from the test-only candidate package entry and checked from installed tarballs; not exported from the published package root. A rejected credential (401 or 403) is an auth error and another HTTP status is carried on a server error. Client-tool evidence, a status check and a failure without a response are not represented in the core fields." }, { "id": "source:libs/ag-ui/src/runtime/child-projection.ts", diff --git a/scripts/react-parity/runtime-consumer.mjs b/scripts/react-parity/runtime-consumer.mjs index a8b4f238a..893b09b69 100644 --- a/scripts/react-parity/runtime-consumer.mjs +++ b/scripts/react-parity/runtime-consumer.mjs @@ -308,8 +308,11 @@ export function assertTextTranscript(messages: readonly Message[]) { child.messages[0].content = 'changed'; // @ts-expect-error Child streams have no execution commands. child.submit('Run'); - // @ts-expect-error Child streams have no executable tool list. - void child.toolCalls; + // A child's tool calls are observations of the child graph; nothing here runs them. + // @ts-expect-error Child tool calls are immutable. + child.toolCalls.push(child.toolCalls[0]); + // @ts-expect-error Child streams have no tool execution command. + child.addToolResult('id', 'result'); if (child.state) { // @ts-expect-error Child values are readonly plain data. child.state['stage'] = 'changed'; diff --git a/scripts/react-parity/verify-langgraph-candidate.mjs b/scripts/react-parity/verify-langgraph-candidate.mjs index 3b2586a6e..941653a7b 100644 --- a/scripts/react-parity/verify-langgraph-candidate.mjs +++ b/scripts/react-parity/verify-langgraph-candidate.mjs @@ -391,7 +391,7 @@ export async function verifyLangGraphCandidate({ const emission = emitCandidate(root, candidate); assert.equal( emission.sources.length, - 35, + 36, 'Complete reviewed backend graph' ); const packed = packCandidate(candidate, temporary);