@librechat/agents 3.8.4 → 3.8.6
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 +7 -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/ToolNode.cjs +134 -32
- 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 +123 -29
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/toolBatchReplay.cjs +65 -13
- 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 +6 -6
- 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/ToolNode.mjs +135 -33
- 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 +123 -29
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/toolBatchReplay.mjs +64 -13
- 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/ToolNode.d.ts +4 -2
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +7 -4
- package/dist/types/tools/toolBatchReplay.d.ts +6 -3
- 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 +11 -1
- package/package.json +1 -1
- 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/ToolNode.ts +528 -149
- package/src/tools/local/LocalProgrammaticToolCalling.ts +1 -0
- package/src/tools/subagent/SubagentExecutionRegistry.ts +0 -1
- package/src/tools/subagent/SubagentExecutor.ts +216 -48
- package/src/tools/toolBatchReplay.ts +121 -20
- package/src/types/graph.ts +37 -0
- package/src/types/run.ts +2 -0
- package/src/types/tools.ts +11 -1
- package/src/utils/llmConfig.ts +0 -1
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,
|
package/src/stream.ts
CHANGED
|
@@ -805,6 +805,21 @@ function startEagerToolExecutions(args: {
|
|
|
805
805
|
return;
|
|
806
806
|
}
|
|
807
807
|
|
|
808
|
+
const codeSessionBaselineById = new Map(
|
|
809
|
+
entries.map((entry) => [
|
|
810
|
+
entry.id,
|
|
811
|
+
new Map(
|
|
812
|
+
(entry.request.codeSessionContext?.files ?? []).map((file) => [
|
|
813
|
+
file.name,
|
|
814
|
+
`${file.storage_session_id}\0${file.id}`,
|
|
815
|
+
])
|
|
816
|
+
),
|
|
817
|
+
])
|
|
818
|
+
);
|
|
819
|
+
for (const entry of entries) {
|
|
820
|
+
entry.request.codeSessionBaselineId =
|
|
821
|
+
entry.request.codeSessionContext?.session_id;
|
|
822
|
+
}
|
|
808
823
|
const records: t.EagerEventToolExecution[] = [];
|
|
809
824
|
const promise: Promise<t.EagerEventToolExecutionOutcome> = new Promise<
|
|
810
825
|
t.ToolExecuteResult[]
|
|
@@ -818,6 +833,7 @@ function startEagerToolExecutions(args: {
|
|
|
818
833
|
}
|
|
819
834
|
};
|
|
820
835
|
const batchRequest: t.ToolExecuteBatchRequest = {
|
|
836
|
+
executionContext: graph.subagentExecutionContext,
|
|
821
837
|
toolCalls: entries.map((entry) => entry.request),
|
|
822
838
|
userId: graph.config?.configurable?.user_id as string | undefined,
|
|
823
839
|
agentId: agentContext?.agentId,
|
|
@@ -826,10 +842,14 @@ function startEagerToolExecutions(args: {
|
|
|
826
842
|
| Partial<Pick<AgentContext, 'getCallerCapabilityProjectionSnapshot'>>
|
|
827
843
|
| undefined
|
|
828
844
|
)?.getCallerCapabilityProjectionSnapshot?.(),
|
|
829
|
-
configurable:
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
845
|
+
configurable: {
|
|
846
|
+
...graph.config?.configurable,
|
|
847
|
+
executionContext: graph.subagentExecutionContext,
|
|
848
|
+
},
|
|
849
|
+
metadata: {
|
|
850
|
+
...metadata,
|
|
851
|
+
executionContext: graph.subagentExecutionContext,
|
|
852
|
+
},
|
|
833
853
|
signal: composeAbortSignals(
|
|
834
854
|
graph.config?.signal,
|
|
835
855
|
graph.breakerAbort.signal
|
|
@@ -873,6 +893,7 @@ function startEagerToolExecutions(args: {
|
|
|
873
893
|
toolName: entry.toolName,
|
|
874
894
|
args: entry.coercedArgs,
|
|
875
895
|
request: entry.request,
|
|
896
|
+
codeSessionBaselineByName: codeSessionBaselineById.get(entry.id),
|
|
876
897
|
promise,
|
|
877
898
|
};
|
|
878
899
|
records.push(record);
|
|
@@ -1653,7 +1674,8 @@ export class ChatModelStreamHandler implements t.EventHandler {
|
|
|
1653
1674
|
if (
|
|
1654
1675
|
eventBreaker != null &&
|
|
1655
1676
|
eventBreaker.signal.aborted &&
|
|
1656
|
-
(eventBreaker.signal.reason instanceof StreamLimitExceededError ||
|
|
1677
|
+
(eventBreaker.signal.reason instanceof StreamLimitExceededError ||
|
|
1678
|
+
eventBreaker.signal.reason instanceof PreparedSubagentError)
|
|
1657
1679
|
) {
|
|
1658
1680
|
throw eventBreaker.signal.reason;
|
|
1659
1681
|
}
|
|
@@ -924,6 +924,7 @@ async function dispatchCompletionEvents(params: {
|
|
|
924
924
|
runId: sessionId,
|
|
925
925
|
threadId,
|
|
926
926
|
agentId,
|
|
927
|
+
executionContext: graph.getSubagentExecutionContext?.(),
|
|
927
928
|
summary: summaryText,
|
|
928
929
|
messagesAfterCount,
|
|
929
930
|
},
|
|
@@ -948,6 +949,7 @@ interface CreateSummarizeNodeParams {
|
|
|
948
949
|
config?: RunnableConfig;
|
|
949
950
|
runId?: string;
|
|
950
951
|
isMultiAgent: boolean;
|
|
952
|
+
getSubagentExecutionContext?: () => t.SubagentExecutionContext | undefined;
|
|
951
953
|
hookRegistry?: HookRegistry;
|
|
952
954
|
getToolsForBinding?: (
|
|
953
955
|
provider: t.ProviderName,
|
|
@@ -1331,6 +1333,7 @@ export function createSummarizeNode({
|
|
|
1331
1333
|
runId: sessionId,
|
|
1332
1334
|
threadId,
|
|
1333
1335
|
agentId: request.agentId,
|
|
1336
|
+
executionContext: graph.getSubagentExecutionContext?.(),
|
|
1334
1337
|
messagesBeforeCount: messagesToRefine.length,
|
|
1335
1338
|
trigger:
|
|
1336
1339
|
request.reason === 'manual'
|