@librechat/agents 3.5.0 → 3.6.0
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 +5 -2
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +148 -22
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +2 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/main.cjs +4 -0
- package/dist/cjs/run.cjs +29 -11
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/stream.cjs +8 -6
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/BashExecutor.cjs +8 -7
- package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +5 -4
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +26 -7
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +7 -6
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +33 -10
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearch.cjs +1 -1
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
- package/dist/cjs/tools/runStepResume.cjs +51 -0
- package/dist/cjs/tools/runStepResume.cjs.map +1 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +15 -43
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentReplay.cjs +6 -1
- package/dist/cjs/tools/subagent/SubagentReplay.cjs.map +1 -1
- package/dist/cjs/utils/toolSessions.cjs +63 -0
- package/dist/cjs/utils/toolSessions.cjs.map +1 -0
- package/dist/esm/agents/AgentContext.mjs +5 -2
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +148 -22
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +2 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/main.mjs +2 -2
- package/dist/esm/run.mjs +29 -11
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/stream.mjs +8 -6
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/BashExecutor.mjs +9 -8
- package/dist/esm/tools/BashExecutor.mjs.map +1 -1
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +6 -5
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +23 -8
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +8 -7
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +33 -10
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearch.mjs +2 -2
- package/dist/esm/tools/ToolSearch.mjs.map +1 -1
- package/dist/esm/tools/runStepResume.mjs +48 -0
- package/dist/esm/tools/runStepResume.mjs.map +1 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +15 -43
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentReplay.mjs +6 -1
- package/dist/esm/tools/subagent/SubagentReplay.mjs.map +1 -1
- package/dist/esm/utils/toolSessions.mjs +62 -0
- package/dist/esm/utils/toolSessions.mjs.map +1 -0
- package/dist/types/agents/AgentContext.d.ts +7 -4
- package/dist/types/agents/projection.d.ts +1 -1
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphs/Graph.d.ts +22 -14
- package/dist/types/graphs/MultiAgentGraph.d.ts +2 -2
- package/dist/types/graphs/createGraph.d.ts +4 -4
- package/dist/types/graphs/graphFactory.d.ts +1 -1
- package/dist/types/hitl/askUserQuestion.d.ts +1 -1
- package/dist/types/hitl/askUserQuestions.d.ts +1 -1
- package/dist/types/hitl/askUserQuestionsInterrupt.d.ts +1 -1
- package/dist/types/hooks/types.d.ts +1 -1
- package/dist/types/instrumentation.d.ts +1 -1
- package/dist/types/langfuse.d.ts +3 -3
- package/dist/types/langfuseConfig.d.ts +2 -2
- package/dist/types/langfuseRuntimeContext.d.ts +1 -1
- package/dist/types/langfuseRuntimeScope.d.ts +2 -2
- package/dist/types/langfuseSpanRegistry.d.ts +1 -1
- package/dist/types/langfuseToolOutputTracing.d.ts +3 -3
- package/dist/types/llm/anthropic/index.d.ts +1 -1
- package/dist/types/llm/bedrock/index.d.ts +1 -1
- package/dist/types/llm/bedrock/toolCache.d.ts +2 -2
- package/dist/types/llm/contextOverflowRecovery.d.ts +2 -2
- package/dist/types/llm/google/index.d.ts +1 -1
- package/dist/types/llm/init.d.ts +2 -2
- package/dist/types/llm/invoke.d.ts +6 -6
- package/dist/types/llm/mistral/index.d.ts +1 -1
- package/dist/types/llm/openai/index.d.ts +2 -2
- package/dist/types/llm/openrouter/index.d.ts +2 -2
- package/dist/types/llm/openrouter/toolCache.d.ts +2 -2
- package/dist/types/llm/providers.d.ts +2 -2
- package/dist/types/llm/request.d.ts +2 -2
- package/dist/types/llm/stream/chunkAdapters.d.ts +1 -1
- package/dist/types/llm/streamLimits.d.ts +1 -1
- package/dist/types/llm/truncation.d.ts +1 -1
- package/dist/types/llm/vertexai/index.d.ts +1 -1
- package/dist/types/messages/alternation.d.ts +1 -1
- package/dist/types/messages/anthropicToolCache.d.ts +2 -2
- package/dist/types/messages/assistantPhase.d.ts +3 -3
- package/dist/types/messages/budget.d.ts +1 -1
- package/dist/types/messages/cache.d.ts +1 -1
- package/dist/types/messages/contextPruning.d.ts +2 -2
- package/dist/types/messages/core.d.ts +2 -2
- package/dist/types/messages/format.d.ts +2 -2
- package/dist/types/messages/ids.d.ts +2 -2
- package/dist/types/messages/injected.d.ts +1 -1
- package/dist/types/messages/langchain.d.ts +1 -1
- package/dist/types/messages/prune.d.ts +3 -3
- package/dist/types/openai/index.d.ts +1 -1
- package/dist/types/prompts/activityLabel.d.ts +2 -2
- package/dist/types/responses/index.d.ts +1 -1
- package/dist/types/run.d.ts +3 -3
- package/dist/types/session/handlers.d.ts +1 -1
- package/dist/types/session/types.d.ts +1 -1
- package/dist/types/stream.d.ts +4 -4
- package/dist/types/summarization/index.d.ts +1 -1
- package/dist/types/summarization/node.d.ts +6 -6
- package/dist/types/tools/BashExecutor.d.ts +2 -2
- package/dist/types/tools/BashProgrammaticToolCalling.d.ts +2 -2
- package/dist/types/tools/CodeExecutor.d.ts +7 -3
- package/dist/types/tools/CodeSessionFileSummary.d.ts +1 -1
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +3 -3
- package/dist/types/tools/ReadFile.d.ts +1 -1
- package/dist/types/tools/SkillTool.d.ts +1 -1
- package/dist/types/tools/SubagentTool.d.ts +3 -3
- package/dist/types/tools/ToolNode.d.ts +8 -6
- package/dist/types/tools/ToolSearch.d.ts +2 -2
- package/dist/types/tools/cloudflare/CloudflareBridgeRuntime.d.ts +1 -1
- package/dist/types/tools/cloudflare/CloudflareProgrammaticToolCalling.d.ts +1 -1
- package/dist/types/tools/cloudflare/CloudflareSandboxExecutionEngine.d.ts +2 -2
- package/dist/types/tools/cloudflare/CloudflareSandboxTools.d.ts +1 -1
- package/dist/types/tools/eagerEventExecution.d.ts +1 -1
- package/dist/types/tools/handlers.d.ts +3 -3
- package/dist/types/tools/intentArg.d.ts +1 -1
- package/dist/types/tools/local/CompileCheckTool.d.ts +2 -2
- package/dist/types/tools/local/FileCheckpointer.d.ts +1 -1
- package/dist/types/tools/local/LocalCodingTools.d.ts +2 -2
- package/dist/types/tools/local/LocalExecutionEngine.d.ts +1 -1
- package/dist/types/tools/local/LocalExecutionTools.d.ts +1 -1
- package/dist/types/tools/local/LocalProgrammaticToolCalling.d.ts +1 -1
- package/dist/types/tools/local/bashAst.d.ts +1 -1
- package/dist/types/tools/local/resolveLocalExecutionTools.d.ts +1 -1
- package/dist/types/tools/local/syntaxCheck.d.ts +1 -1
- package/dist/types/tools/ptcTimeout.d.ts +1 -1
- package/dist/types/tools/runStepResume.d.ts +5 -0
- package/dist/types/tools/schema.d.ts +1 -1
- package/dist/types/tools/search/anthropic.d.ts +1 -1
- package/dist/types/tools/skillCatalog.d.ts +1 -1
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +30 -5
- package/dist/types/tools/subagent/SubagentReplay.d.ts +4 -3
- package/dist/types/tools/subagent/childGraphConfig.d.ts +2 -2
- package/dist/types/types/activityLabel.d.ts +3 -3
- package/dist/types/types/graph.d.ts +16 -7
- package/dist/types/types/llm.d.ts +9 -9
- package/dist/types/types/run.d.ts +7 -7
- package/dist/types/types/stream.d.ts +23 -5
- package/dist/types/types/summarize.d.ts +2 -2
- package/dist/types/types/tools.d.ts +41 -21
- package/dist/types/utils/errors.d.ts +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/handlers.d.ts +3 -3
- package/dist/types/utils/llm.d.ts +1 -1
- package/dist/types/utils/llmConfig.d.ts +1 -1
- package/dist/types/utils/title.d.ts +1 -1
- package/dist/types/utils/toolSessions.d.ts +18 -0
- package/package.json +28 -32
- package/src/agents/AgentContext.ts +7 -0
- package/src/graphs/Graph.ts +192 -13
- package/src/graphs/MultiAgentGraph.ts +1 -0
- package/src/run.ts +62 -11
- package/src/stream.ts +28 -9
- package/src/tools/BashExecutor.ts +31 -13
- package/src/tools/BashProgrammaticToolCalling.ts +19 -9
- package/src/tools/CodeExecutor.ts +57 -16
- package/src/tools/ProgrammaticToolCalling.ts +26 -12
- package/src/tools/ToolNode.ts +58 -8
- package/src/tools/ToolSearch.ts +2 -2
- package/src/tools/runStepResume.ts +121 -0
- package/src/tools/subagent/SubagentExecutor.ts +67 -65
- package/src/tools/subagent/SubagentReplay.ts +22 -1
- package/src/types/graph.ts +10 -0
- package/src/types/stream.ts +17 -0
- package/src/types/tools.ts +50 -21
- package/src/utils/toolSessions.ts +113 -0
- package/dist/types/agents/__tests__/promptCacheLiveHelpers.d.ts +0 -52
- package/dist/types/test/mockTools.d.ts +0 -28
- package/dist/types/utils/__tests__/fixtures/contextOverflowSignatures.d.ts +0 -40
package/src/types/tools.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// src/types/tools.ts
|
|
2
2
|
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
RunnableConfig,
|
|
5
|
+
RunnableToolLike,
|
|
6
|
+
} from '@langchain/core/runnables';
|
|
4
7
|
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
5
8
|
import type { ToolOutputReferenceRegistry } from '@/tools/toolOutputReferences';
|
|
6
9
|
import type { RunBreakerScope } from '@/llm/streamLimits';
|
|
7
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
MessageContentComplex,
|
|
12
|
+
RunStepResumeState,
|
|
13
|
+
ToolErrorData,
|
|
14
|
+
} from './stream';
|
|
8
15
|
import type { HumanInTheLoopConfig } from './hitl';
|
|
9
16
|
import type { LangfuseConfig } from './graph';
|
|
10
17
|
import type { HookRegistry } from '@/hooks';
|
|
@@ -128,6 +135,8 @@ export type ToolNodeOptions = {
|
|
|
128
135
|
toolRegistry?: LCToolRegistry;
|
|
129
136
|
/** Reference to Graph's sessions map for automatic session injection */
|
|
130
137
|
sessions?: ToolSessionMap;
|
|
138
|
+
/** Partition within `sessions` used by this agent's code tools. */
|
|
139
|
+
codeSessionKey?: string;
|
|
131
140
|
/** When true, dispatches ON_TOOL_EXECUTE events instead of invoking tools directly */
|
|
132
141
|
eventDrivenMode?: boolean;
|
|
133
142
|
/** Tool definitions for event-driven mode (used for context, not invocation) */
|
|
@@ -274,6 +283,13 @@ export type ToolNodeOptions = {
|
|
|
274
283
|
* controller.
|
|
275
284
|
*/
|
|
276
285
|
getRunScope?: () => RunBreakerScope;
|
|
286
|
+
/** SDK-owned checkpoint bridge for open run-step lifecycle state. */
|
|
287
|
+
restoreRunStepResumeState?: (
|
|
288
|
+
state?: RunStepResumeState,
|
|
289
|
+
config?: RunnableConfig
|
|
290
|
+
) => void;
|
|
291
|
+
/** SDK-owned checkpoint snapshot for open run-step lifecycle state. */
|
|
292
|
+
createRunStepResumeState?: () => RunStepResumeState;
|
|
277
293
|
};
|
|
278
294
|
|
|
279
295
|
export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
|
|
@@ -375,6 +391,19 @@ export type CodeEnvFile =
|
|
|
375
391
|
export type CodeExecutionToolParams =
|
|
376
392
|
| undefined
|
|
377
393
|
| {
|
|
394
|
+
/** Trusted Code API endpoint selected by the host for this agent. */
|
|
395
|
+
baseUrl?: string;
|
|
396
|
+
/**
|
|
397
|
+
* Expected Code API execution profile. Sent as a request assertion so
|
|
398
|
+
* endpoint/configuration drift fails closed instead of silently using
|
|
399
|
+
* the wrong sandbox backend.
|
|
400
|
+
*/
|
|
401
|
+
executionProfile?: CodeApiExecutionProfile;
|
|
402
|
+
/**
|
|
403
|
+
* Trusted warm-runtime affinity hint selected by the host for this
|
|
404
|
+
* agent invocation. This overrides the legacy ToolNode-injected hint.
|
|
405
|
+
*/
|
|
406
|
+
runtimeSessionHint?: string;
|
|
378
407
|
/** Execution session — see `CodeSessionContext.session_id`. */
|
|
379
408
|
session_id?: string;
|
|
380
409
|
user_id?: string;
|
|
@@ -382,16 +411,16 @@ export type CodeExecutionToolParams =
|
|
|
382
411
|
/** Optional host-supplied Code API auth headers. */
|
|
383
412
|
authHeaders?: CodeApiAuthHeaders;
|
|
384
413
|
/**
|
|
385
|
-
* Advertise
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* `toolExecution.sandbox.statefulSessions` gate, which drives the wire
|
|
390
|
-
* hint — set both from one flag so the prompt and the backend agree.
|
|
414
|
+
* Advertise filesystem-tier stateful sessions in the tool description
|
|
415
|
+
* and allow a trusted runtime affinity hint onto the wire. Resolve this,
|
|
416
|
+
* `baseUrl`, `executionProfile`, and `runtimeSessionHint` together from
|
|
417
|
+
* the executing agent so the prompt and backend agree.
|
|
391
418
|
*/
|
|
392
419
|
statefulSessions?: boolean;
|
|
393
420
|
};
|
|
394
421
|
|
|
422
|
+
export type CodeApiExecutionProfile = 'default' | 'stateful';
|
|
423
|
+
|
|
395
424
|
export type CodeApiAuthHeaderMap = Record<string, string>;
|
|
396
425
|
|
|
397
426
|
export type CodeApiAuthHeaders =
|
|
@@ -1106,19 +1135,17 @@ export type CloudflareSandboxExecutionConfig = {
|
|
|
1106
1135
|
|
|
1107
1136
|
export type SandboxExecutionConfig = {
|
|
1108
1137
|
/**
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1138
|
+
* Legacy run-scoped opt-in for warm runtime hint injection. New hosts that
|
|
1139
|
+
* need mixed execution profiles should resolve `statefulSessions`,
|
|
1140
|
+
* `baseUrl`, `executionProfile`, and `runtimeSessionHint` on each executing
|
|
1141
|
+
* agent's tool factories instead. Direct executors ignore this injected hint
|
|
1142
|
+
* unless their own factory has `statefulSessions: true`.
|
|
1113
1143
|
*
|
|
1114
1144
|
* It does NOT change the model-facing tool description. Tool descriptions are
|
|
1115
1145
|
* bound to the LLM at construction time (`createCodeExecutionTool` /
|
|
1116
1146
|
* `createBashExecutionTool`), before this run config is applied inside the
|
|
1117
1147
|
* graph, so they can only be adjusted via the tools' own `statefulSessions`
|
|
1118
|
-
* factory param.
|
|
1119
|
-
* the factory param off, the backend runs statefully while the model is still
|
|
1120
|
-
* told the environment is stateless (non-corrupting — the model just won't
|
|
1121
|
-
* exploit persistence).
|
|
1148
|
+
* factory param.
|
|
1122
1149
|
*/
|
|
1123
1150
|
statefulSessions?: boolean;
|
|
1124
1151
|
/**
|
|
@@ -1294,6 +1321,10 @@ export type BashProgrammaticToolCallingParams = ProgrammaticToolCallingParams;
|
|
|
1294
1321
|
export type ProgrammaticToolCallingParams = {
|
|
1295
1322
|
/** Code API base URL (or use CODE_BASEURL env var) */
|
|
1296
1323
|
baseUrl?: string;
|
|
1324
|
+
/** Expected Code API execution profile (host-controlled). */
|
|
1325
|
+
executionProfile?: CodeApiExecutionProfile;
|
|
1326
|
+
/** Trusted warm-runtime affinity hint for this agent invocation. */
|
|
1327
|
+
runtimeSessionHint?: string;
|
|
1297
1328
|
/** Safety limit for round-trips (default: 20) */
|
|
1298
1329
|
maxRoundTrips?: number;
|
|
1299
1330
|
/** Maximum per-sandbox-run timeout for PTC's legacy `timeout` field. */
|
|
@@ -1304,11 +1335,9 @@ export type ProgrammaticToolCallingParams = {
|
|
|
1304
1335
|
debug?: boolean;
|
|
1305
1336
|
/** Optional host-supplied Code API auth headers. */
|
|
1306
1337
|
authHeaders?: CodeApiAuthHeaders;
|
|
1307
|
-
/* No `statefulSessions` here: PTC
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1310
|
-
* to advertise (it would be a no-op). Re-add with real behavior when PTC
|
|
1311
|
-
* stateful prompting lands. */
|
|
1338
|
+
/* No `statefulSessions` here: PTC keeps a stateless runtime prompt in v1.
|
|
1339
|
+
* An explicit stateful execution profile may still use a warm filesystem;
|
|
1340
|
+
* runtime/in-memory state never carries across calls. */
|
|
1312
1341
|
};
|
|
1313
1342
|
|
|
1314
1343
|
// ============================================================================
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type * as t from '@/types';
|
|
2
|
+
import { Constants } from '@/common';
|
|
3
|
+
|
|
4
|
+
type CodeSessionAgent = Pick<t.AgentInputs, 'codeSessionKey' | 'initialSessions'>;
|
|
5
|
+
|
|
6
|
+
function cloneToolSessionContext(
|
|
7
|
+
context: t.ToolSessionContext
|
|
8
|
+
): t.ToolSessionContext {
|
|
9
|
+
return {
|
|
10
|
+
...context,
|
|
11
|
+
...(context.files == null
|
|
12
|
+
? {}
|
|
13
|
+
: {
|
|
14
|
+
files: context.files.map((file) => ({
|
|
15
|
+
...file,
|
|
16
|
+
storage_session_id:
|
|
17
|
+
file.storage_session_id ?? context.session_id,
|
|
18
|
+
})),
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function mergeToolSessionContext(
|
|
24
|
+
sessions: t.ToolSessionMap,
|
|
25
|
+
key: string,
|
|
26
|
+
context: t.ToolSessionContext
|
|
27
|
+
): void {
|
|
28
|
+
const existing = sessions.get(key);
|
|
29
|
+
if (existing == null) {
|
|
30
|
+
sessions.set(key, cloneToolSessionContext(context));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (context.files == null || context.files.length === 0) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const seenFiles = new Set(
|
|
38
|
+
existing.files?.map(
|
|
39
|
+
(file) =>
|
|
40
|
+
`${file.storage_session_id ?? existing.session_id}\0${file.id}`
|
|
41
|
+
) ?? []
|
|
42
|
+
);
|
|
43
|
+
const files = existing.files == null ? [] : [...existing.files];
|
|
44
|
+
for (const file of context.files) {
|
|
45
|
+
const storageSessionId = file.storage_session_id ?? context.session_id;
|
|
46
|
+
const fileKey = `${storageSessionId}\0${file.id}`;
|
|
47
|
+
if (seenFiles.has(fileKey)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
seenFiles.add(fileKey);
|
|
51
|
+
files.push({ ...file, storage_session_id: storageSessionId });
|
|
52
|
+
}
|
|
53
|
+
sessions.set(key, { ...existing, files });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Seeds a top-level graph while preserving the legacy run-wide session map.
|
|
58
|
+
* A legacy `execute_code` seed is copied into every custom agent partition
|
|
59
|
+
* unless the host already supplied an explicit seed for that partition.
|
|
60
|
+
*/
|
|
61
|
+
export function seedRunInitialSessions(args: {
|
|
62
|
+
sessions: t.ToolSessionMap;
|
|
63
|
+
initialSessions: t.ToolSessionMap;
|
|
64
|
+
agents: Iterable<Pick<t.AgentInputs, 'codeSessionKey'>>;
|
|
65
|
+
}): void {
|
|
66
|
+
const { sessions, initialSessions, agents } = args;
|
|
67
|
+
for (const [key, context] of initialSessions) {
|
|
68
|
+
mergeToolSessionContext(sessions, key, context);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const legacyCodeSession = initialSessions.get(Constants.EXECUTE_CODE);
|
|
72
|
+
if (legacyCodeSession == null) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
for (const agent of agents) {
|
|
76
|
+
const key = agent.codeSessionKey ?? Constants.EXECUTE_CODE;
|
|
77
|
+
if (
|
|
78
|
+
key === Constants.EXECUTE_CODE ||
|
|
79
|
+
initialSessions.has(key) ||
|
|
80
|
+
sessions.has(key)
|
|
81
|
+
) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
sessions.set(key, cloneToolSessionContext(legacyCodeSession));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Seeds an isolated child graph from each selected agent. Legacy code-session
|
|
90
|
+
* entries are remapped to the owning agent's partition before they are merged.
|
|
91
|
+
*/
|
|
92
|
+
export function seedAgentInitialSessions(
|
|
93
|
+
sessions: t.ToolSessionMap,
|
|
94
|
+
agents: Iterable<CodeSessionAgent>
|
|
95
|
+
): void {
|
|
96
|
+
for (const agent of agents) {
|
|
97
|
+
if (agent.initialSessions == null) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const codeSessionKey = agent.codeSessionKey ?? Constants.EXECUTE_CODE;
|
|
101
|
+
const hasExplicitCodeSession =
|
|
102
|
+
codeSessionKey !== Constants.EXECUTE_CODE &&
|
|
103
|
+
agent.initialSessions.has(codeSessionKey);
|
|
104
|
+
for (const [toolName, context] of agent.initialSessions) {
|
|
105
|
+
if (toolName === Constants.EXECUTE_CODE && hasExplicitCodeSession) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const key =
|
|
109
|
+
toolName === Constants.EXECUTE_CODE ? codeSessionKey : toolName;
|
|
110
|
+
mergeToolSessionContext(sessions, key, context);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { UsageMetadata } from '@langchain/core/messages';
|
|
2
|
-
import type { ClientOptions } from '@langchain/openai';
|
|
3
|
-
import type { ChatOpenRouterInput } from '../../llm/openrouter';
|
|
4
|
-
import type * as t from '../../types';
|
|
5
|
-
import { Providers } from '../../common';
|
|
6
|
-
type LivePromptCacheProvider = Providers.ANTHROPIC | Providers.BEDROCK | Providers.OPENROUTER;
|
|
7
|
-
type PromptCacheExpectedSystemBlock = {
|
|
8
|
-
type: 'text';
|
|
9
|
-
text: string;
|
|
10
|
-
cache_control?: {
|
|
11
|
-
type: 'ephemeral';
|
|
12
|
-
ttl?: '1h';
|
|
13
|
-
};
|
|
14
|
-
} | {
|
|
15
|
-
cachePoint: {
|
|
16
|
-
type: 'default';
|
|
17
|
-
ttl?: '1h';
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
type LivePromptCacheClientOptions = t.ClientOptions | t.BedrockAnthropicClientOptions | (ChatOpenRouterInput & {
|
|
21
|
-
configuration?: ClientOptions;
|
|
22
|
-
});
|
|
23
|
-
export declare function buildStableInstructions({ nonce, providerLabel, }: {
|
|
24
|
-
nonce: string;
|
|
25
|
-
providerLabel: string;
|
|
26
|
-
}): string;
|
|
27
|
-
export declare function buildDynamicInstructions({ marker, tailDescription, }: {
|
|
28
|
-
marker: string;
|
|
29
|
-
tailDescription: string;
|
|
30
|
-
}): string;
|
|
31
|
-
export declare function waitForCachePropagation(): Promise<void>;
|
|
32
|
-
export declare function assertSystemPayloadShape({ agentId, provider, clientOptions, stableInstructions, dynamicInstructions, expectedContent, }: {
|
|
33
|
-
agentId: string;
|
|
34
|
-
provider: LivePromptCacheProvider;
|
|
35
|
-
clientOptions: LivePromptCacheClientOptions;
|
|
36
|
-
stableInstructions: string;
|
|
37
|
-
dynamicInstructions: string;
|
|
38
|
-
expectedContent: PromptCacheExpectedSystemBlock[];
|
|
39
|
-
}): Promise<void>;
|
|
40
|
-
export declare function runLiveTurn({ provider, providerLabel, clientOptions, runId, threadId, stableInstructions, dynamicInstructions, }: {
|
|
41
|
-
provider: LivePromptCacheProvider;
|
|
42
|
-
providerLabel: string;
|
|
43
|
-
clientOptions: LivePromptCacheClientOptions;
|
|
44
|
-
runId: string;
|
|
45
|
-
threadId: string;
|
|
46
|
-
stableInstructions: string;
|
|
47
|
-
dynamicInstructions: string;
|
|
48
|
-
}): Promise<{
|
|
49
|
-
text: string;
|
|
50
|
-
usage: UsageMetadata;
|
|
51
|
-
}>;
|
|
52
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
2
|
-
import type { LCToolRegistry } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Mock get_team_members tool - returns list of team members
|
|
5
|
-
*/
|
|
6
|
-
export declare function createGetTeamMembersTool(): StructuredToolInterface;
|
|
7
|
-
/**
|
|
8
|
-
* Mock get_expenses tool - returns expense records for a user
|
|
9
|
-
*/
|
|
10
|
-
export declare function createGetExpensesTool(): StructuredToolInterface;
|
|
11
|
-
/**
|
|
12
|
-
* Mock get_weather tool - returns weather data for a city
|
|
13
|
-
*/
|
|
14
|
-
export declare function createGetWeatherTool(): StructuredToolInterface;
|
|
15
|
-
/**
|
|
16
|
-
* Mock calculator tool - evaluates mathematical expressions
|
|
17
|
-
*/
|
|
18
|
-
export declare function createCalculatorTool(): StructuredToolInterface;
|
|
19
|
-
/**
|
|
20
|
-
* Creates a tool registry for programmatic tool calling tests.
|
|
21
|
-
* Tools are configured with allowed_callers to demonstrate classification.
|
|
22
|
-
*/
|
|
23
|
-
export declare function createProgrammaticToolRegistry(): LCToolRegistry;
|
|
24
|
-
/**
|
|
25
|
-
* Creates a sample tool registry for tool search tests.
|
|
26
|
-
* Includes mix of deferred and non-deferred tools.
|
|
27
|
-
*/
|
|
28
|
-
export declare function createToolSearchToolRegistry(): LCToolRegistry;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provider error signatures captured from live over-limit requests.
|
|
3
|
-
*
|
|
4
|
-
* Every entry below was produced by `src/scripts/context-overflow-probe.ts`
|
|
5
|
-
* sending a prompt past the model's context window and recording what came
|
|
6
|
-
* back. Account identifiers and request ids have been replaced with
|
|
7
|
-
* placeholders; the wording, status codes, and nesting are verbatim.
|
|
8
|
-
*
|
|
9
|
-
* Treat these as evidence, not examples: if a provider changes its wording,
|
|
10
|
-
* re-run the probe and update the fixture rather than loosening the matcher.
|
|
11
|
-
*/
|
|
12
|
-
import { Providers } from '../../../common';
|
|
13
|
-
export interface OverflowSignature {
|
|
14
|
-
provider: Providers;
|
|
15
|
-
model: string;
|
|
16
|
-
/** Class the SDK actually threw, for reference in review. */
|
|
17
|
-
thrownAs: string;
|
|
18
|
-
/**
|
|
19
|
-
* Stand-in for the thrown error carrying exactly the fields the classifier
|
|
20
|
-
* reads. Nested bodies are kept as the strings the SDKs attach.
|
|
21
|
-
*/
|
|
22
|
-
error: Record<string, unknown>;
|
|
23
|
-
expected: {
|
|
24
|
-
kind: 'context_window' | 'request_too_large';
|
|
25
|
-
limitTokens?: number;
|
|
26
|
-
requestedTokens?: number;
|
|
27
|
-
};
|
|
28
|
-
/** Set when the signature is only decidable with caller-side corroboration. */
|
|
29
|
-
requiresContextPressure?: boolean;
|
|
30
|
-
}
|
|
31
|
-
export declare const OVERFLOW_SIGNATURES: readonly OverflowSignature[];
|
|
32
|
-
/**
|
|
33
|
-
* Errors that mention limits, sizes, or tokens but are NOT fixed by
|
|
34
|
-
* compaction. The first two were captured live alongside the signatures
|
|
35
|
-
* above; the rest are the adjacent failures a loose matcher would swallow.
|
|
36
|
-
*/
|
|
37
|
-
export declare const NON_OVERFLOW_SIGNATURES: readonly {
|
|
38
|
-
label: string;
|
|
39
|
-
error: Record<string, unknown>;
|
|
40
|
-
}[];
|