@librechat/agents 3.4.1 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +57 -33
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +81 -33
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/graphs/applyGraphRuntimeConfig.cjs +14 -0
- package/dist/cjs/graphs/applyGraphRuntimeConfig.cjs.map +1 -0
- package/dist/cjs/graphs/createGraph.cjs +15 -0
- package/dist/cjs/graphs/createGraph.cjs.map +1 -0
- package/dist/cjs/graphs/index.cjs +1 -0
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +1 -1
- package/dist/cjs/main.cjs +20 -11
- package/dist/cjs/run.cjs +48 -38
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/session/JsonlSessionStore.cjs +2 -2
- package/dist/cjs/tools/SubagentTool.cjs +4 -4
- package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +13 -9
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/eagerEventExecution.cjs +1 -0
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs +3 -3
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +2 -2
- package/dist/cjs/tools/search/rerankers.cjs +154 -1
- package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +4 -1
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs +601 -0
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +672 -343
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentReplay.cjs +3 -1
- package/dist/cjs/tools/subagent/SubagentReplay.cjs.map +1 -1
- package/dist/cjs/tools/subagent/childGraphConfig.cjs +278 -0
- package/dist/cjs/tools/subagent/childGraphConfig.cjs.map +1 -0
- package/dist/cjs/tools/subagent/index.cjs +1 -0
- package/dist/cjs/tools/subagent/runtimeLimits.cjs +5 -0
- package/dist/cjs/tools/subagent/runtimeLimits.cjs.map +1 -0
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +57 -33
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +81 -33
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/graphs/applyGraphRuntimeConfig.mjs +14 -0
- package/dist/esm/graphs/applyGraphRuntimeConfig.mjs.map +1 -0
- package/dist/esm/graphs/createGraph.mjs +15 -0
- package/dist/esm/graphs/createGraph.mjs.map +1 -0
- package/dist/esm/graphs/index.mjs +1 -0
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs +1 -1
- package/dist/esm/main.mjs +12 -10
- package/dist/esm/run.mjs +48 -38
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/session/JsonlSessionStore.mjs +2 -2
- package/dist/esm/tools/SubagentTool.mjs +4 -4
- package/dist/esm/tools/SubagentTool.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +13 -9
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/eagerEventExecution.mjs +1 -1
- package/dist/esm/tools/local/LocalExecutionEngine.mjs +3 -3
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +2 -2
- package/dist/esm/tools/search/rerankers.mjs +154 -1
- package/dist/esm/tools/search/rerankers.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +4 -1
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs +597 -0
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +672 -343
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentReplay.mjs +3 -1
- package/dist/esm/tools/subagent/SubagentReplay.mjs.map +1 -1
- package/dist/esm/tools/subagent/childGraphConfig.mjs +272 -0
- package/dist/esm/tools/subagent/childGraphConfig.mjs.map +1 -0
- package/dist/esm/tools/subagent/index.mjs +1 -0
- package/dist/esm/tools/subagent/runtimeLimits.mjs +5 -0
- package/dist/esm/tools/subagent/runtimeLimits.mjs.map +1 -0
- package/dist/types/agents/AgentContext.d.ts +1 -1
- package/dist/types/graphs/Graph.d.ts +7 -2
- package/dist/types/graphs/MultiAgentGraph.d.ts +7 -1
- package/dist/types/graphs/applyGraphRuntimeConfig.d.ts +3 -0
- package/dist/types/graphs/createGraph.d.ts +13 -0
- package/dist/types/graphs/graphFactory.d.ts +13 -0
- package/dist/types/graphs/index.d.ts +2 -0
- package/dist/types/run.d.ts +2 -2
- package/dist/types/tools/SubagentTool.d.ts +1 -1
- package/dist/types/tools/search/rerankers.d.ts +28 -0
- package/dist/types/tools/search/types.d.ts +38 -1
- package/dist/types/tools/subagent/SubagentExecutionRegistry.d.ts +171 -0
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +32 -37
- package/dist/types/tools/subagent/SubagentReplay.d.ts +5 -1
- package/dist/types/tools/subagent/childGraphConfig.d.ts +37 -0
- package/dist/types/tools/subagent/index.d.ts +1 -1
- package/dist/types/tools/subagent/runtimeLimits.d.ts +4 -0
- package/dist/types/types/graph.d.ts +184 -19
- package/package.json +5 -3
- package/src/agents/AgentContext.ts +1 -1
- package/src/graphs/Graph.ts +111 -60
- package/src/graphs/MultiAgentGraph.ts +149 -47
- package/src/graphs/__tests__/MultiAgentGraph.test.ts +86 -0
- package/src/graphs/__tests__/composition.smoke.test.ts +152 -0
- package/src/graphs/__tests__/createGraph.test.ts +206 -0
- package/src/graphs/applyGraphRuntimeConfig.ts +25 -0
- package/src/graphs/createGraph.ts +32 -0
- package/src/graphs/graphFactory.ts +12 -0
- package/src/graphs/index.ts +2 -0
- package/src/run.ts +50 -38
- package/src/specs/graph-subagent.live.test.ts +242 -0
- package/src/specs/graph-subagent.test.ts +322 -0
- package/src/specs/langfuse-routing.integration.test.ts +120 -1
- package/src/specs/subagent.test.ts +130 -4
- package/src/tools/SubagentTool.ts +4 -4
- package/src/tools/ToolNode.ts +22 -10
- package/src/tools/__tests__/SubagentExecutor.test.ts +198 -9
- package/src/tools/__tests__/SubagentReplay.test.ts +29 -0
- package/src/tools/__tests__/directToolHITLResumeScope.test.ts +28 -2
- package/src/tools/__tests__/subagentHooks.test.ts +90 -3
- package/src/tools/search/rag-api-reranker.test.ts +891 -0
- package/src/tools/search/rerankers.ts +260 -0
- package/src/tools/search/tool.ts +6 -0
- package/src/tools/search/types.ts +45 -1
- package/src/tools/subagent/SubagentExecutionRegistry.ts +1159 -0
- package/src/tools/subagent/SubagentExecutor.ts +1245 -563
- package/src/tools/subagent/SubagentReplay.ts +10 -1
- package/src/tools/subagent/__tests__/SubagentExecutionRegistry.test.ts +637 -0
- package/src/tools/subagent/__tests__/SubagentExecutor.lazy.test.ts +3054 -0
- package/src/tools/subagent/__tests__/childGraphConfig.test.ts +521 -0
- package/src/tools/subagent/childGraphConfig.ts +694 -0
- package/src/tools/subagent/index.ts +6 -0
- package/src/tools/subagent/runtimeLimits.ts +7 -0
- package/src/types/graph.ts +217 -19
package/src/types/graph.ts
CHANGED
|
@@ -80,8 +80,14 @@ export type AgentSubgraphState = BaseGraphState & {
|
|
|
80
80
|
summarizationRequest?: SummarizationNodeInput;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
+
export type SubagentGraphResult = {
|
|
84
|
+
agentId: string;
|
|
85
|
+
message?: BaseMessage;
|
|
86
|
+
};
|
|
87
|
+
|
|
83
88
|
export type MultiAgentGraphState = BaseGraphState & {
|
|
84
89
|
agentMessages?: BaseMessage[];
|
|
90
|
+
subagentResult?: SubagentGraphResult;
|
|
85
91
|
};
|
|
86
92
|
|
|
87
93
|
export type IState = BaseGraphState;
|
|
@@ -331,9 +337,9 @@ export type StandardGraphInput = {
|
|
|
331
337
|
indexTokenCountMap?: Record<string, number>;
|
|
332
338
|
calibrationRatio?: number;
|
|
333
339
|
/**
|
|
334
|
-
* Receives a {@link SubagentUsageEvent} for every model call
|
|
335
|
-
* a subagent child run spawned from this graph
|
|
336
|
-
* subagents and child-side summarization calls). Child graphs run via
|
|
340
|
+
* Receives a {@link SubagentUsageEvent} for every model call that reports
|
|
341
|
+
* usage metadata inside a subagent child run spawned from this graph
|
|
342
|
+
* (including nested subagents and child-side summarization calls). Child graphs run via
|
|
337
343
|
* `invoke()` outside the host's `streamEvents` loop, so their
|
|
338
344
|
* `on_chat_model_end` events never reach the run's handler registry —
|
|
339
345
|
* this sink is the only way hosts can observe child token usage for
|
|
@@ -364,10 +370,12 @@ export type StandardGraphInput = {
|
|
|
364
370
|
* every streamed chunk event. See {@link StreamLimits}.
|
|
365
371
|
*/
|
|
366
372
|
streamLimits?: StreamLimits;
|
|
373
|
+
/** Structured lineage for a graph executing as a subagent child. */
|
|
374
|
+
subagentExecutionContext?: SubagentExecutionContext;
|
|
367
375
|
};
|
|
368
376
|
|
|
369
377
|
export type GraphEdge = {
|
|
370
|
-
/** Agent ID
|
|
378
|
+
/** Agent ID; direct edges use an array as an all-of waiting source group. */
|
|
371
379
|
from: string | string[];
|
|
372
380
|
/** Agent ID, use a list for multiple destinations */
|
|
373
381
|
to: string | string[];
|
|
@@ -403,32 +411,184 @@ export type GraphEdge = {
|
|
|
403
411
|
promptKey?: string;
|
|
404
412
|
};
|
|
405
413
|
|
|
414
|
+
export type GraphSubagentEdge = Omit<
|
|
415
|
+
GraphEdge,
|
|
416
|
+
'edgeType' | 'condition' | 'promptKey'
|
|
417
|
+
> & {
|
|
418
|
+
edgeType: 'direct';
|
|
419
|
+
condition?: never;
|
|
420
|
+
promptKey?: never;
|
|
421
|
+
};
|
|
422
|
+
|
|
406
423
|
export type MultiAgentGraphInput = StandardGraphInput & {
|
|
407
424
|
edges: GraphEdge[];
|
|
425
|
+
/** Captures the designated member's final AI turn in graph state. */
|
|
426
|
+
resultAgentId?: string;
|
|
427
|
+
/** Optional per-member Pregel budget when the outer graph has its own topology budget. */
|
|
428
|
+
memberRecursionLimit?: number;
|
|
408
429
|
};
|
|
409
430
|
|
|
410
|
-
/**
|
|
411
|
-
export
|
|
412
|
-
/**
|
|
431
|
+
/** Lightweight identity advertised to the model for a spawnable subagent. */
|
|
432
|
+
export interface SubagentDescriptor {
|
|
433
|
+
/** Stable identifier used in the tool's `subagent_type` enum (e.g. 'researcher', 'coder'). */
|
|
413
434
|
type: string;
|
|
414
435
|
/** Human-readable display name. */
|
|
415
436
|
name: string;
|
|
416
437
|
/** What this subagent specializes in — shown to the LLM. */
|
|
417
438
|
description: string;
|
|
418
|
-
/**
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
439
|
+
/**
|
|
440
|
+
* Opaque, versioned identity of the child configuration. Required when
|
|
441
|
+
* `resolveAgentInputs` is used and changed whenever its resolved inputs
|
|
442
|
+
* change incompatibly.
|
|
443
|
+
*/
|
|
444
|
+
configId?: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** Lazy descriptor with the durable configuration identity required to resolve it. */
|
|
448
|
+
export interface LazySubagentDescriptor extends SubagentDescriptor {
|
|
449
|
+
configId: string;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** Stable request identifiers exposed to a selected subagent resolver. */
|
|
453
|
+
export interface SubagentResolveRequestContext {
|
|
454
|
+
conversationId?: string;
|
|
455
|
+
messageId?: string;
|
|
456
|
+
parentMessageId?: string;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** Stable user identifiers exposed to a selected subagent resolver. */
|
|
460
|
+
export interface SubagentResolveUserContext {
|
|
461
|
+
id?: string;
|
|
462
|
+
role?: string;
|
|
463
|
+
tenantId?: string;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** Sanitized host runtime context safe for lazy subagent resolution. */
|
|
467
|
+
export interface SubagentResolveConfigurable {
|
|
468
|
+
requestBody?: Readonly<SubagentResolveRequestContext>;
|
|
469
|
+
user?: Readonly<SubagentResolveUserContext>;
|
|
470
|
+
user_id?: string;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** Runtime context supplied when a host lazily resolves a selected subagent. */
|
|
474
|
+
export interface SubagentResolveContext {
|
|
475
|
+
/** Stable subagent identity selected by the model. */
|
|
476
|
+
descriptor: Readonly<LazySubagentDescriptor>;
|
|
477
|
+
/** Stable child execution identity, including across HITL reconstruction. */
|
|
478
|
+
executionId: string;
|
|
479
|
+
/** Parent run that dispatched this execution. */
|
|
480
|
+
parentRunId: string;
|
|
481
|
+
/** Parent agent that dispatched this execution. */
|
|
482
|
+
parentAgentId?: string;
|
|
483
|
+
/** Parent-side tool call that selected the subagent. */
|
|
484
|
+
parentToolCallId?: string;
|
|
485
|
+
/** Durable parent conversation thread, when supplied by the host. */
|
|
486
|
+
threadId?: string;
|
|
487
|
+
/** Parent/breaker cancellation composed for this child execution. */
|
|
488
|
+
signal: AbortSignal;
|
|
489
|
+
/** Stable, sanitized host context from the parent tool invocation. */
|
|
490
|
+
configurable?: Readonly<SubagentResolveConfigurable>;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** Host contract for resolving a selected subagent's full graph inputs. */
|
|
494
|
+
export type SubagentAgentInputsResolver = (
|
|
495
|
+
context: SubagentResolveContext
|
|
496
|
+
) => Promise<AgentInputs>;
|
|
497
|
+
|
|
498
|
+
interface SubagentConfigBase extends SubagentDescriptor {
|
|
422
499
|
/** Max AGENT→TOOLS cycles before forced stop (default: 25). */
|
|
423
500
|
maxTurns?: number;
|
|
424
501
|
/** Allow this subagent to spawn its own subagents (default: false). */
|
|
425
502
|
allowNested?: boolean;
|
|
426
|
-
}
|
|
503
|
+
}
|
|
427
504
|
|
|
428
|
-
|
|
429
|
-
|
|
505
|
+
export interface SubagentConfig extends SubagentConfigBase {
|
|
506
|
+
/** Full agent config for the child graph. Omit when `self` is true. */
|
|
507
|
+
agentInputs?: AgentInputs;
|
|
508
|
+
/**
|
|
509
|
+
* Resolve the full child config only after this descriptor is selected.
|
|
510
|
+
* Eager `agentInputs` take precedence when also supplied. `self` and a
|
|
511
|
+
* resolver are mutually exclusive and normalization rejects that pairing.
|
|
512
|
+
*
|
|
513
|
+
* Resolvers should rebuild inputs from the stable execution context instead
|
|
514
|
+
* of retaining request-owned state. The SDK keeps resolved inputs in memory
|
|
515
|
+
* only for the lifetime of the selected execution and supplies cancellation
|
|
516
|
+
* through `context.signal`. A reconstructed execution may invoke the
|
|
517
|
+
* resolver again, so the same `context.executionId` must produce equivalent
|
|
518
|
+
* child inputs. Durable resolver work should be idempotent on
|
|
519
|
+
* `(context.executionId, context.descriptor.configId)`.
|
|
520
|
+
*/
|
|
521
|
+
resolveAgentInputs?: SubagentAgentInputsResolver;
|
|
522
|
+
/** When true, reuse the parent's AgentInputs (context isolation without separate config). */
|
|
523
|
+
self?: boolean;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export interface SingleAgentSubagentConfig extends SubagentConfig {
|
|
527
|
+
kind?: 'agent';
|
|
528
|
+
agents?: never;
|
|
529
|
+
edges?: never;
|
|
530
|
+
entryAgentId?: never;
|
|
531
|
+
resultAgentId?: never;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export interface GraphSubagentConfig extends SubagentConfigBase {
|
|
535
|
+
kind: 'graph';
|
|
536
|
+
configId?: never;
|
|
537
|
+
resolveAgentInputs?: never;
|
|
538
|
+
allowNested?: false;
|
|
539
|
+
agents: AgentInputs[];
|
|
540
|
+
/**
|
|
541
|
+
* Explicit direct DAG edges. Array-valued sources are all-of waiting edges.
|
|
542
|
+
* Relative message order between parallel branches is implementation-dependent.
|
|
543
|
+
* Prompted edges are supported in chains or on the final converged result transition.
|
|
544
|
+
*/
|
|
545
|
+
edges: GraphSubagentEdge[];
|
|
546
|
+
entryAgentId: string;
|
|
547
|
+
resultAgentId: string;
|
|
548
|
+
agentInputs?: never;
|
|
549
|
+
self?: never;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/** Any configuration that can be spawned through the subagent tool. */
|
|
553
|
+
export type SubagentConfigEntry = SubagentConfig | GraphSubagentConfig;
|
|
554
|
+
|
|
555
|
+
/** Legacy single-agent config with self-spawn resolution completed. */
|
|
556
|
+
export interface ResolvedSubagentConfig extends SubagentConfig {
|
|
430
557
|
agentInputs: AgentInputs;
|
|
431
|
-
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** Explicit alias for graph-aware code that needs to name the legacy variant. */
|
|
561
|
+
export interface ResolvedSingleAgentSubagentConfig
|
|
562
|
+
extends ResolvedSubagentConfig {
|
|
563
|
+
kind?: 'agent';
|
|
564
|
+
agents?: never;
|
|
565
|
+
edges?: never;
|
|
566
|
+
entryAgentId?: never;
|
|
567
|
+
resultAgentId?: never;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export type ResolvedSubagentConfigEntry =
|
|
571
|
+
| ResolvedSubagentConfig
|
|
572
|
+
| GraphSubagentConfig;
|
|
573
|
+
|
|
574
|
+
/** Lazy single-agent entry accepted after descriptor validation. */
|
|
575
|
+
export interface LazySingleAgentSubagentConfig
|
|
576
|
+
extends SingleAgentSubagentConfig {
|
|
577
|
+
configId: string;
|
|
578
|
+
resolveAgentInputs: SubagentAgentInputsResolver;
|
|
579
|
+
agentInputs?: never;
|
|
580
|
+
self?: never;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** Single-agent config accepted after eager/self/lazy eligibility checks. */
|
|
584
|
+
export type ExecutableSubagentConfig =
|
|
585
|
+
| ResolvedSubagentConfig
|
|
586
|
+
| LazySingleAgentSubagentConfig;
|
|
587
|
+
|
|
588
|
+
/** Graph-aware config accepted by the executor. Graph configs stay eager. */
|
|
589
|
+
export type ExecutableSubagentConfigEntry =
|
|
590
|
+
| ExecutableSubagentConfig
|
|
591
|
+
| GraphSubagentConfig;
|
|
432
592
|
|
|
433
593
|
/** Lifecycle phase carried on {@link SubagentUpdateEvent}. */
|
|
434
594
|
export type SubagentUpdatePhase =
|
|
@@ -441,14 +601,34 @@ export type SubagentUpdatePhase =
|
|
|
441
601
|
| 'stop'
|
|
442
602
|
| 'error';
|
|
443
603
|
|
|
604
|
+
export interface SubagentAncestryEntry {
|
|
605
|
+
readonly subagentRunId: string;
|
|
606
|
+
readonly subagentType: string;
|
|
607
|
+
readonly subagentKind: 'agent' | 'graph';
|
|
608
|
+
/** Execution subject ID; synthetic for graph subagents. */
|
|
609
|
+
readonly subagentAgentId: string;
|
|
610
|
+
readonly parentRunId: string;
|
|
611
|
+
readonly parentAgentId?: string;
|
|
612
|
+
readonly parentToolCallId?: string;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
export interface SubagentExecutionContext {
|
|
616
|
+
readonly rootRunId: string;
|
|
617
|
+
readonly hookSessionId: string;
|
|
618
|
+
readonly depth: number;
|
|
619
|
+
readonly ancestry: readonly SubagentAncestryEntry[];
|
|
620
|
+
}
|
|
621
|
+
|
|
444
622
|
/**
|
|
445
623
|
* Wrapper event emitted when a subagent's child graph dispatches activity.
|
|
446
624
|
* Lets hosts show subagent progress in a UI surface separate from the parent
|
|
447
625
|
* conversation without having to untangle events by agent ID.
|
|
448
626
|
*/
|
|
449
627
|
export interface SubagentUpdateEvent {
|
|
450
|
-
/**
|
|
628
|
+
/** Root run ID that owns this execution tree. */
|
|
451
629
|
runId: string;
|
|
630
|
+
/** Immediate parent run that spawned this child. */
|
|
631
|
+
parentRunId?: string;
|
|
452
632
|
/** Child run ID (unique per subagent execution). */
|
|
453
633
|
subagentRunId: string;
|
|
454
634
|
/**
|
|
@@ -460,8 +640,16 @@ export interface SubagentUpdateEvent {
|
|
|
460
640
|
parentToolCallId?: string;
|
|
461
641
|
/** Subagent `type` identifier from the SubagentConfig. */
|
|
462
642
|
subagentType: string;
|
|
463
|
-
/**
|
|
643
|
+
/** Execution shape. Omitted by older emitters. */
|
|
644
|
+
subagentKind?: 'agent' | 'graph';
|
|
645
|
+
/** Execution subject ID; synthetic for graph subagents. */
|
|
464
646
|
subagentAgentId: string;
|
|
647
|
+
/** Graph member that produced this update, when attributable. */
|
|
648
|
+
memberAgentId?: string;
|
|
649
|
+
/** One-based nesting depth beneath the root graph. */
|
|
650
|
+
depth?: number;
|
|
651
|
+
/** Root-to-leaf execution lineage, without parsing composed run IDs. */
|
|
652
|
+
ancestry?: readonly SubagentAncestryEntry[];
|
|
465
653
|
/** Parent agent ID that spawned this subagent. */
|
|
466
654
|
parentAgentId?: string;
|
|
467
655
|
/** Lifecycle phase carried by this update. */
|
|
@@ -504,10 +692,20 @@ export interface SubagentUsageEvent {
|
|
|
504
692
|
provider?: string;
|
|
505
693
|
/** Subagent `type` identifier from the SubagentConfig. */
|
|
506
694
|
subagentType: string;
|
|
695
|
+
/** Execution shape. Omitted by older emitters. */
|
|
696
|
+
subagentKind?: 'agent' | 'graph';
|
|
507
697
|
/** Child run ID (unique per subagent execution). */
|
|
508
698
|
subagentRunId: string;
|
|
509
|
-
/**
|
|
699
|
+
/** Execution subject ID; synthetic for graph subagents. */
|
|
510
700
|
subagentAgentId: string;
|
|
701
|
+
/** Graph member whose model call produced this usage. */
|
|
702
|
+
memberAgentId?: string;
|
|
703
|
+
/** Immediate parent run that spawned this child. */
|
|
704
|
+
parentRunId?: string;
|
|
705
|
+
/** One-based nesting depth beneath the root graph. */
|
|
706
|
+
depth?: number;
|
|
707
|
+
/** Root-to-leaf execution lineage, without parsing composed run IDs. */
|
|
708
|
+
ancestry?: readonly SubagentAncestryEntry[];
|
|
511
709
|
/**
|
|
512
710
|
* ROOT run ID of the host run that owns billing. For nested subagents
|
|
513
711
|
* each forwarding layer rewrites this upward, so events from any depth
|
|
@@ -647,7 +845,7 @@ export interface AgentInputs {
|
|
|
647
845
|
/** Pre-computed tool schema token count (from cache). Skips recalculation when provided. */
|
|
648
846
|
toolSchemaTokens?: number;
|
|
649
847
|
/** Subagent configurations for hierarchical delegation. Each defines a child agent type. */
|
|
650
|
-
subagentConfigs?:
|
|
848
|
+
subagentConfigs?: SubagentConfigEntry[];
|
|
651
849
|
/** Maximum subagent nesting depth. Default 1 means top-level agents can spawn subagents but subagents cannot nest further. */
|
|
652
850
|
maxSubagentDepth?: number;
|
|
653
851
|
/**
|