@librechat/agents 3.8.5 → 3.8.7
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 +1 -1
- package/dist/cjs/common/constants.cjs +2 -0
- package/dist/cjs/common/constants.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +18 -9
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/hitl/approvalReview.cjs +1 -1
- package/dist/cjs/hooks/types.cjs.map +1 -1
- package/dist/cjs/main.cjs +8 -6
- package/dist/cjs/messages/index.cjs +1 -1
- package/dist/cjs/messages/prune.cjs +1 -1
- package/dist/cjs/run.cjs +7 -3
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/stream.cjs +13 -3
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +3 -1
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/BashExecutor.cjs +79 -27
- package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +47 -7
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +5 -2
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/CodeSessionFileSummary.cjs +11 -1
- package/dist/cjs/tools/CodeSessionFileSummary.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +54 -8
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +176 -43
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +1 -0
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs +0 -1
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +120 -26
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/toolBatchReplay.cjs +4 -2
- package/dist/cjs/tools/toolBatchReplay.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/esm/agents/AgentContext.mjs +1 -1
- package/dist/esm/common/constants.mjs +2 -1
- package/dist/esm/common/constants.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +17 -8
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/hitl/approvalReview.mjs +1 -1
- package/dist/esm/hooks/types.mjs.map +1 -1
- package/dist/esm/main.mjs +7 -7
- package/dist/esm/messages/index.mjs +1 -1
- package/dist/esm/messages/prune.mjs +1 -1
- package/dist/esm/run.mjs +7 -3
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/stream.mjs +13 -3
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +3 -1
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/BashExecutor.mjs +81 -29
- package/dist/esm/tools/BashExecutor.mjs.map +1 -1
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +48 -9
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +5 -2
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/CodeSessionFileSummary.mjs +11 -2
- package/dist/esm/tools/CodeSessionFileSummary.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +55 -9
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +176 -43
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +1 -0
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs +0 -1
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +120 -26
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/toolBatchReplay.mjs +4 -2
- package/dist/esm/tools/toolBatchReplay.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/types/common/constants.d.ts +2 -0
- package/dist/types/graphs/Graph.d.ts +3 -2
- package/dist/types/hooks/types.d.ts +3 -0
- package/dist/types/run.d.ts +1 -0
- package/dist/types/summarization/node.d.ts +1 -0
- package/dist/types/tools/BashExecutor.d.ts +2 -0
- package/dist/types/tools/BashProgrammaticToolCalling.d.ts +1 -0
- package/dist/types/tools/CodeExecutor.d.ts +1 -1
- package/dist/types/tools/CodeSessionFileSummary.d.ts +3 -0
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +2 -2
- package/dist/types/tools/ToolNode.d.ts +6 -2
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +7 -4
- package/dist/types/tools/toolBatchReplay.d.ts +2 -0
- package/dist/types/types/graph.d.ts +28 -0
- package/dist/types/types/run.d.ts +2 -0
- package/dist/types/types/tools.d.ts +27 -3
- package/package.json +2 -2
- package/src/common/constants.ts +3 -0
- package/src/graphs/Graph.ts +32 -18
- package/src/hooks/types.ts +3 -0
- package/src/run.ts +30 -15
- package/src/stream.ts +27 -5
- package/src/summarization/node.ts +3 -0
- package/src/tools/BashExecutor.ts +143 -40
- package/src/tools/BashProgrammaticToolCalling.ts +82 -10
- package/src/tools/CodeExecutor.ts +12 -2
- package/src/tools/CodeSessionFileSummary.ts +25 -1
- package/src/tools/ProgrammaticToolCalling.ts +77 -6
- package/src/tools/ToolNode.ts +665 -170
- package/src/tools/local/LocalProgrammaticToolCalling.ts +1 -0
- package/src/tools/subagent/SubagentExecutionRegistry.ts +0 -1
- package/src/tools/subagent/SubagentExecutor.ts +214 -55
- package/src/tools/toolBatchReplay.ts +23 -1
- package/src/types/graph.ts +37 -0
- package/src/types/run.ts +2 -0
- package/src/types/tools.ts +30 -3
- package/src/utils/llmConfig.ts +0 -1
|
@@ -11,6 +11,7 @@ export declare const BashProgrammaticToolCallingDefinition: {
|
|
|
11
11
|
readonly description: string;
|
|
12
12
|
readonly schema: ProgrammaticToolCallingJsonSchema;
|
|
13
13
|
};
|
|
14
|
+
export declare function prepareBashProgrammaticCode(code: string): string;
|
|
14
15
|
export declare function normalizeBashToolResultsForReplay(toolResults: t.PTCToolResult[]): t.PTCToolResult[];
|
|
15
16
|
/**
|
|
16
17
|
* Normalizes a tool name to a valid bash function identifier.
|
|
@@ -11,7 +11,7 @@ export declare const CODE_ARTIFACT_PATH_GUIDANCE = "Anything a later call needs
|
|
|
11
11
|
export declare const BASH_SHELL_GUIDANCE = "Bash: multi-line files use heredoc/printf; run Python via python3 -c/heredoc, not bare Python.";
|
|
12
12
|
export declare const TMP_SCRATCH_OUTPUT_REMINDER = "Note: /tmp files are same-call scratch only and were not persisted; use /mnt/data for files needed later.";
|
|
13
13
|
export declare const FAILED_EXECUTION_FILE_REMINDER = "Note: any files written during this failed call were not registered for later calls; fix the error and rerun before relying on them.";
|
|
14
|
-
export declare function appendTmpScratchReminder(output: string, code: string): string;
|
|
14
|
+
export declare function appendTmpScratchReminder(output: string, code: string, reminder?: string): string;
|
|
15
15
|
export declare function appendFailedExecutionFileReminder(output: string, code: string): string;
|
|
16
16
|
export declare const CodeExecutionToolSchema: {
|
|
17
17
|
readonly type: "object";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type * as t from '@/types';
|
|
2
2
|
export declare function stripCodeSessionFileSummary(output: string): string;
|
|
3
3
|
export declare function appendCodeSessionFileSummary(output: string, files: t.FileRefs | undefined): string;
|
|
4
|
+
/** Attached-worker artifacts are delivered out of execution-private scratch,
|
|
5
|
+
* not retained in the selected project or a reusable `/mnt/data` session. */
|
|
6
|
+
export declare function appendExecutionArtifactFileSummary(output: string, files: t.FileRefs | undefined): string;
|
|
@@ -66,7 +66,7 @@ export declare function fetchSessionFiles(baseUrl: string, sessionId: string, sc
|
|
|
66
66
|
* @param proxy - Optional HTTP proxy URL
|
|
67
67
|
* @returns The parsed API response
|
|
68
68
|
*/
|
|
69
|
-
export declare function makeRequest(endpoint: string, body: Record<string, unknown>, proxy?: string, authHeaders?: t.CodeApiAuthHeaders, executionProfile?: t.CodeApiExecutionProfile): Promise<t.ProgrammaticExecutionResponse>;
|
|
69
|
+
export declare function makeRequest(endpoint: string, body: Record<string, unknown>, proxy?: string, authHeaders?: t.CodeApiAuthHeaders, executionProfile?: t.CodeApiExecutionProfile, signal?: AbortSignal): Promise<t.ProgrammaticExecutionResponse>;
|
|
70
70
|
/**
|
|
71
71
|
* Unwraps tool responses that may be formatted as tuples or content blocks.
|
|
72
72
|
* MCP tools return [content, artifacts], we need to extract the raw data.
|
|
@@ -94,7 +94,7 @@ export declare function executeTools(toolCalls: t.PTCToolCall[], toolMap: t.Tool
|
|
|
94
94
|
* @param response - The completed API response
|
|
95
95
|
* @returns Tuple of [formatted string, artifact]
|
|
96
96
|
*/
|
|
97
|
-
export declare function formatCompletedResponse(response: t.ProgrammaticExecutionResponse, sourceCode?: string): [string, t.ProgrammaticExecutionArtifact];
|
|
97
|
+
export declare function formatCompletedResponse(response: t.ProgrammaticExecutionResponse, sourceCode?: string, filePersistence?: 'session' | 'execution'): [string, t.ProgrammaticExecutionArtifact];
|
|
98
98
|
/**
|
|
99
99
|
* Mirrors the Code API's programmatic Python wrapper (`wrapUserCodeInAsync`).
|
|
100
100
|
*
|
|
@@ -21,6 +21,8 @@ type RunToolBatchContext<T = unknown> = {
|
|
|
21
21
|
batchScopeId?: string;
|
|
22
22
|
/** Batch-local sink for post-substitution args. */
|
|
23
23
|
resolvedArgsByCallId?: ResolvedArgsByCallId;
|
|
24
|
+
/** File identities actually injected into each direct code call. */
|
|
25
|
+
codeSessionBaselineByCallId?: Map<string, ReadonlyMap<string, string>>;
|
|
24
26
|
/**
|
|
25
27
|
* Frozen pre-batch view of the tool-output registry. When supplied,
|
|
26
28
|
* `runTool` resolves `{{tool…turn…}}` placeholders against this
|
|
@@ -161,6 +163,7 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
161
163
|
* even where `agentId` (the subagent-scope marker) is undefined.
|
|
162
164
|
*/
|
|
163
165
|
private executingAgentId?;
|
|
166
|
+
private readonly executionContext?;
|
|
164
167
|
private executingAgentName?;
|
|
165
168
|
private rootAgentId?;
|
|
166
169
|
private rootAgentName?;
|
|
@@ -225,7 +228,7 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
225
228
|
* other's in-flight state.
|
|
226
229
|
*/
|
|
227
230
|
private anonBatchCounter;
|
|
228
|
-
constructor({ tools, toolMap, name, tags, trace, runLangfuse, agentLangfuse, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, toolDefinitions, getDiscoveredToolNames, sessions, codeSessionKey, eventDrivenMode, eagerEventToolExecution, eagerEventToolExecutions, eagerEventToolUsageCount, eagerEventToolSuppressions, agentId, executingAgentId, executingAgentName, rootAgentId, rootAgentName, directToolNames, interruptingToolNames, codeSessionToolNames, maxContextTokens, maxToolResultChars, hookRegistry, humanInTheLoop, toolOutputReferences, toolOutputRegistry, toolExecution, fileCheckpointer, getBreakerSignal, getRunScope, preparedSubagents, restoreRunStepResumeState, createRunStepResumeState, }: t.ToolNodeConstructorParams);
|
|
231
|
+
constructor({ tools, toolMap, name, tags, trace, runLangfuse, agentLangfuse, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, toolDefinitions, getDiscoveredToolNames, sessions, codeSessionKey, eventDrivenMode, eagerEventToolExecution, eagerEventToolExecutions, eagerEventToolUsageCount, eagerEventToolSuppressions, agentId, executingAgentId, executionContext, executingAgentName, rootAgentId, rootAgentName, directToolNames, interruptingToolNames, codeSessionToolNames, maxContextTokens, maxToolResultChars, hookRegistry, humanInTheLoop, toolOutputReferences, toolOutputRegistry, toolExecution, fileCheckpointer, getBreakerSignal, getRunScope, preparedSubagents, restoreRunStepResumeState, createRunStepResumeState, }: t.ToolNodeConstructorParams);
|
|
229
232
|
invoke(input: any, options?: Partial<RunnableConfig>): Promise<any>;
|
|
230
233
|
private withToolScope;
|
|
231
234
|
/**
|
|
@@ -411,6 +414,7 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
411
414
|
* paths derive the runtime session hint identically. */
|
|
412
415
|
private resolveRuntimeSessionHint;
|
|
413
416
|
private storeCodeSessionFromResults;
|
|
417
|
+
private retainCodeSessionInputsFromRequests;
|
|
414
418
|
/**
|
|
415
419
|
* Post-processes standard runTool outputs: dispatches ON_RUN_STEP_COMPLETED
|
|
416
420
|
* and stores code session context. Mirrors the completion handling in
|
|
@@ -531,7 +535,7 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
531
535
|
* invocations cannot race on shared mutable state.
|
|
532
536
|
*/
|
|
533
537
|
private executeViaEvent;
|
|
534
|
-
protected run(input:
|
|
538
|
+
protected run(input: T, config: RunnableConfig, referenceReplay?: {
|
|
535
539
|
state?: ToolOutputReferenceState;
|
|
536
540
|
}): Promise<T>;
|
|
537
541
|
private isSendInput;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseMessage } from '@langchain/core/messages';
|
|
2
2
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
3
3
|
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
4
|
-
import type { MultiAgentGraphState, HumanInTheLoopConfig, StandardGraphInput, ExecutableSubagentConfigEntry, SubagentExecutionContext, SubagentTaskConfig, SubagentTaskRuntime, SubagentUsageSink, TokenCounter } from '@/types';
|
|
4
|
+
import type { MultiAgentGraphState, HumanInTheLoopConfig, StandardGraphInput, ExecutableSubagentConfigEntry, SubagentExecutionContext, SubagentContextAdapter, SubagentContextResult, SubagentTaskConfig, SubagentTaskRuntime, SubagentUsageSink, TokenCounter } from '@/types';
|
|
5
5
|
import type { SubagentResumeManifest, SettledSubagentToolOutput } from './SubagentReplay';
|
|
6
6
|
import type { GraphFactory } from '@/graphs/graphFactory';
|
|
7
7
|
import type { StandardGraph } from '@/graphs/Graph';
|
|
@@ -71,11 +71,11 @@ export type SubagentExecuteParams = {
|
|
|
71
71
|
/** Host-restored child transcript for a fresh continuation run. @internal */
|
|
72
72
|
initialMessages?: BaseMessage[];
|
|
73
73
|
};
|
|
74
|
-
export type SubagentExecuteResult = {
|
|
75
|
-
content: string;
|
|
76
|
-
messages: BaseMessage[];
|
|
74
|
+
export type SubagentExecuteResult = SubagentContextResult & {
|
|
77
75
|
/** Tagged internal failure; foreground callers retain the legacy content. */
|
|
78
76
|
error?: string;
|
|
77
|
+
/** Completed child work whose host projection must be retried without re-execution. */
|
|
78
|
+
retryableDelivery?: true;
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
81
|
* Factory that constructs a child graph for subagent execution. Injected
|
|
@@ -160,6 +160,7 @@ export type SubagentExecutorOptions = {
|
|
|
160
160
|
usageSink?: SubagentUsageSink;
|
|
161
161
|
/** Host-owned process-local task namespace for detached execution. */
|
|
162
162
|
taskConfig?: SubagentTaskConfig;
|
|
163
|
+
subagentContext?: SubagentContextAdapter;
|
|
163
164
|
};
|
|
164
165
|
export declare class SubagentExecutor {
|
|
165
166
|
private readonly configs;
|
|
@@ -187,6 +188,7 @@ export declare class SubagentExecutor {
|
|
|
187
188
|
private readonly createDetachedChildGraphFactory?;
|
|
188
189
|
private readonly usageSink?;
|
|
189
190
|
private readonly taskConfig?;
|
|
191
|
+
private readonly subagentContext?;
|
|
190
192
|
private readonly executions;
|
|
191
193
|
private replayCheckpointWorkflow?;
|
|
192
194
|
private readonly resolveParentHandlerRegistry?;
|
|
@@ -266,6 +268,7 @@ export declare class SubagentExecutor {
|
|
|
266
268
|
private persistChildCheckpointMarker;
|
|
267
269
|
execute(params: SubagentExecuteParams): Promise<SubagentExecuteResult>;
|
|
268
270
|
private executeOnce;
|
|
271
|
+
private completeHostContext;
|
|
269
272
|
/**
|
|
270
273
|
* Emits a single {@link GraphEvents.ON_SUBAGENT_UPDATE} envelope through the
|
|
271
274
|
* parent's handler registry. Silent no-op when no parent registry is set.
|
|
@@ -12,6 +12,8 @@ export interface SettledToolBatchResult {
|
|
|
12
12
|
output: BaseMessage | Command;
|
|
13
13
|
additionalContexts: string[];
|
|
14
14
|
resolvedArgs?: Record<string, unknown>;
|
|
15
|
+
/** Code-session identities injected into this completed direct call. */
|
|
16
|
+
codeSessionBaseline?: Array<[string, string]>;
|
|
15
17
|
completionHandled?: boolean;
|
|
16
18
|
referenceContent?: string;
|
|
17
19
|
turn?: number;
|
|
@@ -278,6 +278,8 @@ export type StandardGraphInput = {
|
|
|
278
278
|
* do not inherit it, keeping background nesting disabled for the MVP.
|
|
279
279
|
*/
|
|
280
280
|
subagentTasks?: SubagentTaskConfig;
|
|
281
|
+
/** Host-owned context and result projection for each isolated child execution. */
|
|
282
|
+
subagentContext?: SubagentContextAdapter;
|
|
281
283
|
/**
|
|
282
284
|
* True when this graph IS a subagent child run (set by `SubagentExecutor`
|
|
283
285
|
* when it constructs the child graph). Drives the hook-input `agentId`
|
|
@@ -499,6 +501,32 @@ export interface SubagentExecutionContext {
|
|
|
499
501
|
readonly depth: number;
|
|
500
502
|
readonly ancestry: readonly SubagentAncestryEntry[];
|
|
501
503
|
}
|
|
504
|
+
/** Trusted identity supplied before a child can access host-owned resources. */
|
|
505
|
+
export interface SubagentContextInput {
|
|
506
|
+
executionContext: SubagentExecutionContext;
|
|
507
|
+
parentThreadId?: string;
|
|
508
|
+
memberAgentIds: readonly string[];
|
|
509
|
+
signal: AbortSignal;
|
|
510
|
+
resumed: boolean;
|
|
511
|
+
}
|
|
512
|
+
export interface PreparedSubagentContext {
|
|
513
|
+
/** Added to the initial child input; checkpoint recovery does not add them again. */
|
|
514
|
+
messages?: BaseMessage[];
|
|
515
|
+
/** Host configuration; SDK execution and checkpoint identities remain authoritative. */
|
|
516
|
+
configurable?: RunnableConfig['configurable'];
|
|
517
|
+
/** Each entry replaces that member's inherited code partition and initial sessions. */
|
|
518
|
+
agentSessions?: Readonly<Record<string, Pick<AgentInputs, 'codeSessionKey' | 'initialSessions'>>>;
|
|
519
|
+
}
|
|
520
|
+
export interface SubagentContextResult {
|
|
521
|
+
content: string;
|
|
522
|
+
messages: BaseMessage[];
|
|
523
|
+
}
|
|
524
|
+
export interface SubagentContextAdapter {
|
|
525
|
+
/** Reauthorizes reconstructed executions; durable work must be idempotent by child run ID. */
|
|
526
|
+
prepare(input: SubagentContextInput): Promise<PreparedSubagentContext>;
|
|
527
|
+
/** Projects durable references into the result returned to the parent. */
|
|
528
|
+
complete?(input: SubagentContextInput, result: SubagentContextResult): Promise<Pick<SubagentContextResult, 'content'>>;
|
|
529
|
+
}
|
|
502
530
|
/**
|
|
503
531
|
* Wrapper event emitted when a subagent's child graph dispatches activity.
|
|
504
532
|
* Lets hosts show subagent progress in a UI surface separate from the parent
|
|
@@ -272,6 +272,8 @@ export type RunConfig = {
|
|
|
272
272
|
* Omit to preserve foreground-only subagent behavior.
|
|
273
273
|
*/
|
|
274
274
|
subagentTasks?: SubagentTaskConfig;
|
|
275
|
+
/** Authorizes and supplies host-owned context to isolated child runs. */
|
|
276
|
+
subagentContext?: g.SubagentContextAdapter;
|
|
275
277
|
/**
|
|
276
278
|
* Pre-constructed hook registry for this run. Hooks fire at lifecycle
|
|
277
279
|
* points in `processStream` (RunStart, UserPromptSubmit, Stop,
|
|
@@ -3,10 +3,10 @@ import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
|
3
3
|
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
4
4
|
import type { MessageContentComplex, RunStepResumeState, ToolErrorData } from './stream';
|
|
5
5
|
import type { ToolOutputReferenceRegistry } from '@/tools/toolOutputReferences';
|
|
6
|
+
import type { LangfuseConfig, SubagentExecutionContext } from './graph';
|
|
6
7
|
import type { PreparedSubagents } from '@/tools/preparedSubagents';
|
|
7
8
|
import type { RunBreakerScope } from '@/llm/streamLimits';
|
|
8
9
|
import type { HumanInTheLoopConfig } from './hitl';
|
|
9
|
-
import type { LangfuseConfig } from './graph';
|
|
10
10
|
import type { HookRegistry } from '@/hooks';
|
|
11
11
|
/** Replacement type for `import type { ToolCall } from '@langchain/core/messages/tool'` in order to have stringified args typed */
|
|
12
12
|
export type CustomToolCall = {
|
|
@@ -63,6 +63,7 @@ export type EagerEventToolExecution = {
|
|
|
63
63
|
toolName: string;
|
|
64
64
|
args: Record<string, unknown>;
|
|
65
65
|
request: ToolCallRequest;
|
|
66
|
+
codeSessionBaselineByName?: ReadonlyMap<string, string>;
|
|
66
67
|
promise: Promise<EagerEventToolExecutionOutcome>;
|
|
67
68
|
/**
|
|
68
69
|
* True when the streaming eager path already emitted the user-visible
|
|
@@ -139,6 +140,8 @@ export type ToolNodeOptions = {
|
|
|
139
140
|
/** ID of the agent that owns this tool node, surfaced to hooks as `executingAgentId`
|
|
140
141
|
* so a batch can be attributed to a specific agent even where `agentId` is undefined. */
|
|
141
142
|
executingAgentId?: string;
|
|
143
|
+
/** SDK-owned identity of the child execution, independent of reusable agent IDs. */
|
|
144
|
+
executionContext?: SubagentExecutionContext;
|
|
142
145
|
/** Name of the agent that owns this tool node, used for active Langfuse attribution. */
|
|
143
146
|
executingAgentName?: string;
|
|
144
147
|
/** Root graph-agent identity retained alongside the currently executing tool owner. */
|
|
@@ -466,6 +469,8 @@ export type ExecuteResult = {
|
|
|
466
469
|
stdout: string;
|
|
467
470
|
stderr: string;
|
|
468
471
|
files?: FileRefs;
|
|
472
|
+
/** Persisted input paths explicitly removed during this execution. */
|
|
473
|
+
deleted_files?: string[];
|
|
469
474
|
artifact_delivery?: ArtifactDeliveryFailure;
|
|
470
475
|
/**
|
|
471
476
|
* Durable runtime session id echoed by a stateful Code API backend
|
|
@@ -529,6 +534,10 @@ export type ToolCallRequest = {
|
|
|
529
534
|
session_id: string;
|
|
530
535
|
files?: CodeEnvFile[];
|
|
531
536
|
};
|
|
537
|
+
/** Request-time execution session used to detect host session refreshes. */
|
|
538
|
+
codeSessionBaselineId?: string;
|
|
539
|
+
/** Preserve request-provisioned code inputs after an eager identity mismatch. */
|
|
540
|
+
retainCodeSessionInputs?: true;
|
|
532
541
|
/**
|
|
533
542
|
* Stable runtime session hint for stateful sandbox sessions. Orthogonal to
|
|
534
543
|
* `codeSessionContext` (which threads the transient exec-session for file
|
|
@@ -550,6 +559,8 @@ export type CallerCapabilityProjectionSnapshot = {
|
|
|
550
559
|
};
|
|
551
560
|
/** Batch request containing ALL tool calls for a graph step */
|
|
552
561
|
export type ToolExecuteBatchRequest = {
|
|
562
|
+
/** SDK-owned child lineage. Unset for tools in the root graph. */
|
|
563
|
+
executionContext?: SubagentExecutionContext;
|
|
553
564
|
/** All tool calls from the AIMessage */
|
|
554
565
|
toolCalls: ToolCallRequest[];
|
|
555
566
|
/** User ID for context */
|
|
@@ -1134,6 +1145,7 @@ export type ProgrammaticHookContext = {
|
|
|
1134
1145
|
runId: string;
|
|
1135
1146
|
threadId?: string;
|
|
1136
1147
|
agentId?: string;
|
|
1148
|
+
executionContext?: SubagentExecutionContext;
|
|
1137
1149
|
executingAgentId?: string;
|
|
1138
1150
|
};
|
|
1139
1151
|
/** Search mode: code_interpreter uses external sandbox, local uses safe substring matching */
|
|
@@ -1225,6 +1237,8 @@ export type ProgrammaticExecutionResponse = {
|
|
|
1225
1237
|
stdout?: string;
|
|
1226
1238
|
stderr?: string;
|
|
1227
1239
|
files?: FileRefs;
|
|
1240
|
+
/** Persisted input paths explicitly removed during this execution. */
|
|
1241
|
+
deleted_files?: string[];
|
|
1228
1242
|
artifact_delivery?: ArtifactDeliveryFailure;
|
|
1229
1243
|
/** Durable runtime session echo from a stateful backend (additive). */
|
|
1230
1244
|
runtime_session_id?: string;
|
|
@@ -1239,15 +1253,23 @@ export type ProgrammaticExecutionArtifact = {
|
|
|
1239
1253
|
/** Execution session — see `CodeSessionContext.session_id`. */
|
|
1240
1254
|
session_id?: string;
|
|
1241
1255
|
files?: FileRefs;
|
|
1256
|
+
/** Persisted input paths explicitly removed during this execution. */
|
|
1257
|
+
deleted_files?: string[];
|
|
1242
1258
|
artifact_delivery?: ArtifactDeliveryFailure;
|
|
1243
1259
|
/** Durable runtime session echo from a stateful backend (additive). */
|
|
1244
1260
|
runtime_session_id?: string;
|
|
1245
1261
|
runtime_status?: 'new' | 'reused';
|
|
1246
1262
|
};
|
|
1247
1263
|
/** Parameters for creating a bash execution tool (same API as CodeExecutor, bash-only) */
|
|
1248
|
-
export type BashExecutionToolParams = CodeExecutionToolParams
|
|
1264
|
+
export type BashExecutionToolParams = undefined | (Exclude<CodeExecutionToolParams, undefined> & {
|
|
1265
|
+
/** Trusted attached-workspace identifier selected by the host. */
|
|
1266
|
+
workspaceId?: string;
|
|
1267
|
+
});
|
|
1249
1268
|
/** Parameters for creating a bash programmatic tool calling tool (same API as PTC, bash-only) */
|
|
1250
|
-
export type BashProgrammaticToolCallingParams = ProgrammaticToolCallingParams
|
|
1269
|
+
export type BashProgrammaticToolCallingParams = ProgrammaticToolCallingParams & {
|
|
1270
|
+
/** Trusted attached-workspace identifier selected by the host. */
|
|
1271
|
+
workspaceId?: string;
|
|
1272
|
+
};
|
|
1251
1273
|
/**
|
|
1252
1274
|
* Initialization parameters for the PTC tool
|
|
1253
1275
|
*/
|
|
@@ -1294,6 +1316,8 @@ export type CodeExecutionArtifact = {
|
|
|
1294
1316
|
/** Execution session — see `CodeSessionContext.session_id`. */
|
|
1295
1317
|
session_id?: string;
|
|
1296
1318
|
files?: FileRefs;
|
|
1319
|
+
/** Persisted input paths explicitly removed during this execution. */
|
|
1320
|
+
deleted_files?: string[];
|
|
1297
1321
|
artifact_delivery?: ArtifactDeliveryFailure;
|
|
1298
1322
|
/** Durable runtime session echo from a stateful backend (additive). */
|
|
1299
1323
|
runtime_session_id?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@librechat/agents",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.7",
|
|
4
4
|
"reova": {
|
|
5
5
|
"enabled": true,
|
|
6
6
|
"endpoint": "https://telemetry.reo.dev/data"
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"description": "",
|
|
160
160
|
"repository": {
|
|
161
161
|
"type": "git",
|
|
162
|
-
"url": "https://github.com/
|
|
162
|
+
"url": "https://github.com/LibreChat-AI/agents"
|
|
163
163
|
},
|
|
164
164
|
"author": "Danny Avila",
|
|
165
165
|
"license": "MIT",
|
package/src/common/constants.ts
CHANGED
package/src/graphs/Graph.ts
CHANGED
|
@@ -133,10 +133,18 @@ import {
|
|
|
133
133
|
annotateMessagesForLLM,
|
|
134
134
|
ToolOutputReferenceRegistry,
|
|
135
135
|
} from '@/tools/toolOutputReferences';
|
|
136
|
+
import {
|
|
137
|
+
prepareProviderRequest,
|
|
138
|
+
usesNativeOpenAIResponses,
|
|
139
|
+
} from '@/llm/prepareProviderRequest';
|
|
136
140
|
import {
|
|
137
141
|
resolveLangfuseRuntimeScope,
|
|
138
142
|
withLangfuseRuntimeScope,
|
|
139
143
|
} from '@/langfuseRuntimeScope';
|
|
144
|
+
import {
|
|
145
|
+
ManualSummarizationSkippedError,
|
|
146
|
+
shouldTriggerSummarization,
|
|
147
|
+
} from '@/summarization';
|
|
140
148
|
import {
|
|
141
149
|
getToolContentCharLength,
|
|
142
150
|
serializeToolContentBounded,
|
|
@@ -150,6 +158,11 @@ import {
|
|
|
150
158
|
PreparedSubagents,
|
|
151
159
|
PreparedSubagentError,
|
|
152
160
|
} from '@/tools/preparedSubagents';
|
|
161
|
+
import {
|
|
162
|
+
createRemoveAllMessage,
|
|
163
|
+
messagesStateReducer,
|
|
164
|
+
} from '@/messages/reducer';
|
|
165
|
+
import { createToolHistoryPreparation } from '@/messages/toolHistoryProjection';
|
|
153
166
|
import { ToolNode as CustomToolNode, toolsCondition } from '@/tools/ToolNode';
|
|
154
167
|
import { shouldTraceToolNodeForLangfuse } from '@/langfuseToolOutputTracing';
|
|
155
168
|
import { createLocalCodingToolBundle } from '@/tools/local/LocalCodingTools';
|
|
@@ -157,29 +170,16 @@ import { SUBAGENT_REPLAY_CONTROLLER } from '@/tools/subagent/SubagentReplay';
|
|
|
157
170
|
import { applyGraphRuntimeConfig } from '@/graphs/applyGraphRuntimeConfig';
|
|
158
171
|
import { isFadingTier, isInformativeFadingTier } from '@/messages/fading';
|
|
159
172
|
import { createContextPressureMeter } from '@/llm/contextPressureMeter';
|
|
160
|
-
import { createToolHistoryPreparation } from '@/messages/toolHistoryProjection';
|
|
161
173
|
import { safeDispatchCustomEvent, emitAgentLog } from '@/utils/events';
|
|
162
|
-
import {
|
|
163
|
-
prepareProviderRequest,
|
|
164
|
-
usesNativeOpenAIResponses,
|
|
165
|
-
} from '@/llm/prepareProviderRequest';
|
|
166
174
|
import { createCloudflareCodingToolBundle } from '@/tools/cloudflare';
|
|
167
175
|
import { calculateMaxToolCallInputChars } from '@/utils/truncation';
|
|
168
176
|
import { prepareToolsForPromptCache } from '@/llm/promptCacheTools';
|
|
169
177
|
import { providerRequiresStrictAlternation } from '@/llm/providers';
|
|
170
178
|
import { buildSubagentToolParams } from '@/tools/SubagentTool';
|
|
171
179
|
import { initializeLangfuseTracing } from '@/instrumentation';
|
|
172
|
-
import {
|
|
173
|
-
ManualSummarizationSkippedError,
|
|
174
|
-
shouldTriggerSummarization,
|
|
175
|
-
} from '@/summarization';
|
|
176
180
|
import { isRunStepResumeState } from '@/tools/runStepResume';
|
|
177
181
|
import { resolveLocalToolsForBinding } from '@/tools/local';
|
|
178
182
|
import { createSummarizeNode } from '@/summarization/node';
|
|
179
|
-
import {
|
|
180
|
-
createRemoveAllMessage,
|
|
181
|
-
messagesStateReducer,
|
|
182
|
-
} from '@/messages/reducer';
|
|
183
183
|
import { getTruncationStopReason } from '@/llm/truncation';
|
|
184
184
|
import { createSchemaOnlyTools } from '@/tools/schema';
|
|
185
185
|
import { AgentContext } from '@/agents/AgentContext';
|
|
@@ -1356,7 +1356,8 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1356
1356
|
/** See {@link t.StandardGraphInput.subagentTasks}. */
|
|
1357
1357
|
subagentTasks: t.SubagentTaskConfig | undefined;
|
|
1358
1358
|
/** See {@link t.StandardGraphInput.subagentExecutionContext}. */
|
|
1359
|
-
|
|
1359
|
+
readonly subagentExecutionContext?: t.SubagentExecutionContext;
|
|
1360
|
+
private readonly subagentContext?: t.SubagentContextAdapter;
|
|
1360
1361
|
/** See {@link t.StandardGraphInput.preemption}. */
|
|
1361
1362
|
preemption?: t.StreamPreemption;
|
|
1362
1363
|
/**
|
|
@@ -1534,6 +1535,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1534
1535
|
subagentTasks,
|
|
1535
1536
|
subagentScope,
|
|
1536
1537
|
subagentExecutionContext,
|
|
1538
|
+
subagentContext,
|
|
1537
1539
|
preemption,
|
|
1538
1540
|
streamLimits,
|
|
1539
1541
|
toolExecution,
|
|
@@ -1560,6 +1562,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1560
1562
|
this.subagentTasks = subagentTasks;
|
|
1561
1563
|
this.subagentScope = subagentScope === true;
|
|
1562
1564
|
this.subagentExecutionContext = subagentExecutionContext;
|
|
1565
|
+
this.subagentContext = subagentContext;
|
|
1563
1566
|
this.preemption = preemption;
|
|
1564
1567
|
this.streamLimits = resolveStreamLimits(streamLimits);
|
|
1565
1568
|
this.toolExecution = toolExecution;
|
|
@@ -2881,6 +2884,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
2881
2884
|
// run_id); `executingAgentId` always identifies the owning agent.
|
|
2882
2885
|
agentId: this.subagentScope ? agentContext?.agentId : undefined,
|
|
2883
2886
|
executingAgentId: agentContext?.agentId,
|
|
2887
|
+
executionContext: this.subagentExecutionContext,
|
|
2884
2888
|
executingAgentName: agentContext?.name,
|
|
2885
2889
|
rootAgentId: this.defaultAgentId,
|
|
2886
2890
|
rootAgentName: this.agentContexts.get(this.defaultAgentId)?.name,
|
|
@@ -2965,6 +2969,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
2965
2969
|
// hooks can attribute the batch even at the top level.
|
|
2966
2970
|
agentId: this.subagentScope ? agentContext?.agentId : undefined,
|
|
2967
2971
|
executingAgentId: agentContext?.agentId,
|
|
2972
|
+
executionContext: this.subagentExecutionContext,
|
|
2968
2973
|
executingAgentName: agentContext?.name,
|
|
2969
2974
|
rootAgentId: this.defaultAgentId,
|
|
2970
2975
|
rootAgentName: this.agentContexts.get(this.defaultAgentId)?.name,
|
|
@@ -4627,7 +4632,9 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
4627
4632
|
fallbackProvider,
|
|
4628
4633
|
fallbackClientOptions
|
|
4629
4634
|
);
|
|
4630
|
-
let projection:
|
|
4635
|
+
let projection:
|
|
4636
|
+
| ReturnType<typeof measureProviderPayload>
|
|
4637
|
+
| undefined;
|
|
4631
4638
|
const request = prepareProviderRequest({
|
|
4632
4639
|
model: fallbackModel,
|
|
4633
4640
|
messages: cached,
|
|
@@ -4644,7 +4651,9 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
4644
4651
|
},
|
|
4645
4652
|
});
|
|
4646
4653
|
if (projection == null) {
|
|
4647
|
-
throw new Error(
|
|
4654
|
+
throw new Error(
|
|
4655
|
+
'Fallback preparation did not measure its payload'
|
|
4656
|
+
);
|
|
4648
4657
|
}
|
|
4649
4658
|
return { request, projection };
|
|
4650
4659
|
};
|
|
@@ -4664,8 +4673,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
4664
4673
|
if (!projection.fits) {
|
|
4665
4674
|
const compacted = compactSyntheticProviderContext(
|
|
4666
4675
|
servingFallbackMessages,
|
|
4667
|
-
(candidate) =>
|
|
4668
|
-
prepareFallback(candidate).projection
|
|
4676
|
+
(candidate) => prepareFallback(candidate).projection
|
|
4669
4677
|
);
|
|
4670
4678
|
if (compacted !== servingFallbackMessages) {
|
|
4671
4679
|
preparedFallbackRequest = prepareFallback(compacted);
|
|
@@ -5025,6 +5033,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5025
5033
|
runId,
|
|
5026
5034
|
threadId: configurable?.thread_id as string | undefined,
|
|
5027
5035
|
agentId: this.subagentScope ? agentId : undefined,
|
|
5036
|
+
executionContext: this.subagentExecutionContext,
|
|
5028
5037
|
executingAgentId: agentId,
|
|
5029
5038
|
sealCount: this.preemptSealCount,
|
|
5030
5039
|
},
|
|
@@ -5247,6 +5256,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5247
5256
|
tokenCounter: agentContext.tokenCounter,
|
|
5248
5257
|
usageSink: this.subagentUsageSink,
|
|
5249
5258
|
taskConfig: this.subagentTasks,
|
|
5259
|
+
subagentContext: this.subagentContext,
|
|
5250
5260
|
streamLimits: this.streamLimits,
|
|
5251
5261
|
humanInTheLoop: this.humanInTheLoop,
|
|
5252
5262
|
checkpointer: this.compileOptions?.checkpointer,
|
|
@@ -5343,6 +5353,9 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5343
5353
|
});
|
|
5344
5354
|
}
|
|
5345
5355
|
const result = await executor.execute(executeParams);
|
|
5356
|
+
if (result.retryableDelivery === true) {
|
|
5357
|
+
throw new Error(result.content);
|
|
5358
|
+
}
|
|
5346
5359
|
return result.content;
|
|
5347
5360
|
},
|
|
5348
5361
|
buildSubagentToolParams(executableConfigs, {
|
|
@@ -5527,6 +5540,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5527
5540
|
},
|
|
5528
5541
|
runId: this.runId,
|
|
5529
5542
|
isMultiAgent: this.isMultiAgentGraph(),
|
|
5543
|
+
getSubagentExecutionContext: () => this.subagentExecutionContext,
|
|
5530
5544
|
hookRegistry: this.hookRegistry,
|
|
5531
5545
|
getToolsForBinding: (
|
|
5532
5546
|
provider: t.ProviderName,
|
package/src/hooks/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/hooks/types.ts
|
|
2
2
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
3
|
+
import type { SubagentExecutionContext } from '@/types/graph';
|
|
3
4
|
import type { InjectedMessage } from '@/types/tools';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -57,6 +58,8 @@ export type StopDecision = 'continue' | 'block';
|
|
|
57
58
|
* hook to a specific agent regardless of subagent scope.
|
|
58
59
|
*/
|
|
59
60
|
export interface BaseHookInput {
|
|
61
|
+
/** SDK-owned child lineage, including distinct identities for concurrent self-spawns. */
|
|
62
|
+
executionContext?: SubagentExecutionContext;
|
|
60
63
|
runId: string;
|
|
61
64
|
threadId?: string;
|
|
62
65
|
agentId?: string;
|
package/src/run.ts
CHANGED
|
@@ -37,11 +37,6 @@ import {
|
|
|
37
37
|
DEFAULT_MAX_STOP_CONTINUATIONS,
|
|
38
38
|
DEFAULT_RECURSION_LIMIT,
|
|
39
39
|
} from '@/common';
|
|
40
|
-
import {
|
|
41
|
-
requireValidSubagentResumeManifest,
|
|
42
|
-
SUBAGENT_RESUME_ATTEMPT_CONFIG_KEY,
|
|
43
|
-
SUBAGENT_RESUME_MANIFEST_CONFIG_KEY,
|
|
44
|
-
} from '@/tools/subagent/SubagentReplay';
|
|
45
40
|
import {
|
|
46
41
|
ACTIVITY_PHASE_LABEL_PROMPT,
|
|
47
42
|
ACTIVITY_LABEL_PROMPT,
|
|
@@ -57,12 +52,23 @@ import {
|
|
|
57
52
|
isLangfuseCallbackHandler,
|
|
58
53
|
withLangfuseAttributes,
|
|
59
54
|
} from '@/langfuse';
|
|
55
|
+
import {
|
|
56
|
+
requireValidSubagentResumeManifest,
|
|
57
|
+
SUBAGENT_RESUME_ATTEMPT_CONFIG_KEY,
|
|
58
|
+
SUBAGENT_RESUME_MANIFEST_CONFIG_KEY,
|
|
59
|
+
} from '@/tools/subagent/SubagentReplay';
|
|
60
60
|
import {
|
|
61
61
|
REASONING_LABEL_PROMPT,
|
|
62
62
|
buildReasoningLabelTraceSeed,
|
|
63
63
|
buildReasoningLabelPrompt,
|
|
64
64
|
normalizeReasoningLabel,
|
|
65
65
|
} from '@/prompts/reasoningLabel';
|
|
66
|
+
import {
|
|
67
|
+
TOOL_BATCH_REPLAY_KEY,
|
|
68
|
+
restoreToolReplayConfig,
|
|
69
|
+
stripToolBatchReplayState,
|
|
70
|
+
getPublicToolInterruptPayload,
|
|
71
|
+
} from '@/tools/toolBatchReplay';
|
|
66
72
|
import {
|
|
67
73
|
hasToolOutputTracingConfig,
|
|
68
74
|
resolveLangfuseConfig,
|
|
@@ -72,12 +78,6 @@ import {
|
|
|
72
78
|
cloneToolApprovalInterruptPayload,
|
|
73
79
|
TOOL_APPROVAL_REVIEW_CONFIG_KEY,
|
|
74
80
|
} from '@/hitl/approvalReview';
|
|
75
|
-
import {
|
|
76
|
-
TOOL_BATCH_REPLAY_KEY,
|
|
77
|
-
restoreToolReplayConfig,
|
|
78
|
-
stripToolBatchReplayState,
|
|
79
|
-
getPublicToolInterruptPayload,
|
|
80
|
-
} from '@/tools/toolBatchReplay';
|
|
81
81
|
import {
|
|
82
82
|
resolveLangfuseDestinationKey,
|
|
83
83
|
resolveLangfuseTraceAnchorParent,
|
|
@@ -474,6 +474,7 @@ export class Run<_T extends t.BaseGraphState> {
|
|
|
474
474
|
private maxStopContinuations: number;
|
|
475
475
|
private streamLimits?: t.StreamLimits;
|
|
476
476
|
private subagentTasks?: t.SubagentTaskConfig;
|
|
477
|
+
private subagentContext?: t.SubagentContextAdapter;
|
|
477
478
|
private indexTokenCountMap?: Record<string, number>;
|
|
478
479
|
calibrationRatio: number = 1;
|
|
479
480
|
fadingTier?: t.FadingTier;
|
|
@@ -556,6 +557,7 @@ export class Run<_T extends t.BaseGraphState> {
|
|
|
556
557
|
this.toolExecution = config.toolExecution;
|
|
557
558
|
this.subagentUsageSink = config.subagentUsageSink;
|
|
558
559
|
this.subagentTasks = config.subagentTasks;
|
|
560
|
+
this.subagentContext = config.subagentContext;
|
|
559
561
|
this.preemption = config.preemption;
|
|
560
562
|
this.maxStopContinuations = resolveMaxStopContinuations(
|
|
561
563
|
config.maxStopContinuations
|
|
@@ -654,6 +656,7 @@ export class Run<_T extends t.BaseGraphState> {
|
|
|
654
656
|
fadingTiers: this.fadingTiers,
|
|
655
657
|
subagentUsageSink: this.subagentUsageSink,
|
|
656
658
|
subagentTasks: this.subagentTasks,
|
|
659
|
+
subagentContext: this.subagentContext,
|
|
657
660
|
preemption: this.preemption,
|
|
658
661
|
streamLimits: this.streamLimits,
|
|
659
662
|
toolExecution: this.toolExecution,
|
|
@@ -696,6 +699,7 @@ export class Run<_T extends t.BaseGraphState> {
|
|
|
696
699
|
fadingTiers: this.fadingTiers,
|
|
697
700
|
subagentUsageSink: this.subagentUsageSink,
|
|
698
701
|
subagentTasks: this.subagentTasks,
|
|
702
|
+
subagentContext: this.subagentContext,
|
|
699
703
|
preemption: this.preemption,
|
|
700
704
|
streamLimits: this.streamLimits,
|
|
701
705
|
toolExecution: this.toolExecution,
|
|
@@ -1283,7 +1287,11 @@ export class Run<_T extends t.BaseGraphState> {
|
|
|
1283
1287
|
);
|
|
1284
1288
|
const publicPayload = stripRunStepResumeState(this._interrupt?.payload);
|
|
1285
1289
|
if (config.configurable != null) {
|
|
1286
|
-
restoreToolReplayConfig(
|
|
1290
|
+
restoreToolReplayConfig(
|
|
1291
|
+
config.configurable,
|
|
1292
|
+
this._interrupt?.interruptId,
|
|
1293
|
+
publicPayload
|
|
1294
|
+
);
|
|
1287
1295
|
}
|
|
1288
1296
|
if (graph.getStopContinuationExecutionId() === '') {
|
|
1289
1297
|
graph.startStopContinuationExecution(nanoid());
|
|
@@ -2015,8 +2023,11 @@ export class Run<_T extends t.BaseGraphState> {
|
|
|
2015
2023
|
await this.restoreInterruptFromCheckpoint(callerConfig, resumeUpdate);
|
|
2016
2024
|
const interrupt = this._interrupt;
|
|
2017
2025
|
const replayPayload = stripRunStepResumeState(interrupt?.payload);
|
|
2018
|
-
const resumeManifest =
|
|
2019
|
-
requireValidSubagentResumeManifest(
|
|
2026
|
+
const resumeManifest =
|
|
2027
|
+
requireValidSubagentResumeManifest(replayPayload) ??
|
|
2028
|
+
requireValidSubagentResumeManifest(
|
|
2029
|
+
stripToolBatchReplayState(replayPayload)
|
|
2030
|
+
);
|
|
2020
2031
|
const resumeConfigurable = { ...callerConfig.configurable };
|
|
2021
2032
|
delete resumeConfigurable[TOOL_APPROVAL_REVIEW_CONFIG_KEY];
|
|
2022
2033
|
delete resumeConfigurable[TOOL_BATCH_REPLAY_KEY];
|
|
@@ -2027,7 +2038,11 @@ export class Run<_T extends t.BaseGraphState> {
|
|
|
2027
2038
|
resumeConfigurable[SUBAGENT_RESUME_MANIFEST_CONFIG_KEY] = resumeManifest;
|
|
2028
2039
|
}
|
|
2029
2040
|
const publicPayload = stripRunStepResumeState(interrupt?.payload);
|
|
2030
|
-
restoreToolReplayConfig(
|
|
2041
|
+
restoreToolReplayConfig(
|
|
2042
|
+
resumeConfigurable,
|
|
2043
|
+
interrupt?.interruptId,
|
|
2044
|
+
publicPayload
|
|
2045
|
+
);
|
|
2031
2046
|
const manifestConfig = {
|
|
2032
2047
|
...callerConfig,
|
|
2033
2048
|
configurable: resumeConfigurable,
|