@voltagent/core 0.1.50 → 0.1.52
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/index.d.ts +30 -2
- package/dist/index.js +154 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1102,6 +1102,11 @@ type AgentOptions = {
|
|
|
1102
1102
|
* Sub-agents that this agent can delegate tasks to
|
|
1103
1103
|
*/
|
|
1104
1104
|
subAgents?: any[];
|
|
1105
|
+
/**
|
|
1106
|
+
* Maximum number of steps (turns) the agent can take before stopping
|
|
1107
|
+
* This overrides any supervisor config maxSteps setting
|
|
1108
|
+
*/
|
|
1109
|
+
maxSteps?: number;
|
|
1105
1110
|
/**
|
|
1106
1111
|
* Optional user-defined context to be passed around
|
|
1107
1112
|
*/
|
|
@@ -1214,6 +1219,7 @@ interface CommonGenerateOptions {
|
|
|
1214
1219
|
userId?: string;
|
|
1215
1220
|
contextLimit?: number;
|
|
1216
1221
|
tools?: BaseTool[];
|
|
1222
|
+
maxSteps?: number;
|
|
1217
1223
|
signal?: AbortSignal;
|
|
1218
1224
|
historyEntryId?: string;
|
|
1219
1225
|
operationContext?: OperationContext;
|
|
@@ -1227,7 +1233,7 @@ type PublicGenerateOptions = Omit<CommonGenerateOptions, "historyEntryId" | "ope
|
|
|
1227
1233
|
/**
|
|
1228
1234
|
* Agent status information
|
|
1229
1235
|
*/
|
|
1230
|
-
type AgentStatus = "idle" | "working" | "
|
|
1236
|
+
type AgentStatus = "idle" | "working" | "error" | "completed" | "cancelled";
|
|
1231
1237
|
/**
|
|
1232
1238
|
* Tool call definition
|
|
1233
1239
|
*/
|
|
@@ -1322,6 +1328,15 @@ type AgentHandoffOptions = {
|
|
|
1322
1328
|
* Parent's operation context to merge SubAgent steps into
|
|
1323
1329
|
*/
|
|
1324
1330
|
parentOperationContext?: OperationContext;
|
|
1331
|
+
/**
|
|
1332
|
+
* AbortSignal to cancel the handoff operation
|
|
1333
|
+
*/
|
|
1334
|
+
signal?: AbortSignal;
|
|
1335
|
+
/**
|
|
1336
|
+
* Maximum number of steps for the subagent (inherited from parent or API call)
|
|
1337
|
+
* If not provided, subagent will use its own maxSteps calculation
|
|
1338
|
+
*/
|
|
1339
|
+
maxSteps?: number;
|
|
1325
1340
|
};
|
|
1326
1341
|
/**
|
|
1327
1342
|
* Result of a handoff to another agent
|
|
@@ -1380,6 +1395,8 @@ type OperationContext = {
|
|
|
1380
1395
|
toolSpans?: Map<string, Span>;
|
|
1381
1396
|
/** Conversation steps for building full message history including tool calls/results */
|
|
1382
1397
|
conversationSteps?: StepWithContent[];
|
|
1398
|
+
/** AbortSignal for cancelling the operation */
|
|
1399
|
+
signal?: AbortSignal;
|
|
1383
1400
|
};
|
|
1384
1401
|
/**
|
|
1385
1402
|
* Tool execution context passed to tool.execute method
|
|
@@ -1994,6 +2011,7 @@ type AgentStartEventMetadata = {
|
|
|
1994
2011
|
stop?: string[];
|
|
1995
2012
|
system?: string;
|
|
1996
2013
|
toolChoice?: string;
|
|
2014
|
+
maxSteps?: number;
|
|
1997
2015
|
};
|
|
1998
2016
|
systemPrompt?: string | BaseMessage | BaseMessage[];
|
|
1999
2017
|
messages?: BaseMessage[];
|
|
@@ -2010,6 +2028,7 @@ interface AgentSuccessEventMetadata extends BaseEventMetadata {
|
|
|
2010
2028
|
stop?: string[];
|
|
2011
2029
|
system?: string;
|
|
2012
2030
|
toolChoice?: string;
|
|
2031
|
+
maxSteps?: number;
|
|
2013
2032
|
};
|
|
2014
2033
|
}
|
|
2015
2034
|
interface MemoryEventMetadata extends BaseEventMetadata {
|
|
@@ -3196,7 +3215,7 @@ declare class SubAgentManager {
|
|
|
3196
3215
|
* Calculate maximum number of steps based on sub-agents
|
|
3197
3216
|
* More sub-agents means more potential steps
|
|
3198
3217
|
*/
|
|
3199
|
-
calculateMaxSteps(): number;
|
|
3218
|
+
calculateMaxSteps(agentMaxSteps?: number): number;
|
|
3200
3219
|
/**
|
|
3201
3220
|
* Generate enhanced system message for supervisor role
|
|
3202
3221
|
* @param baseDescription - The base description of the agent
|
|
@@ -3226,6 +3245,7 @@ declare class SubAgentManager {
|
|
|
3226
3245
|
currentHistoryEntryId?: string;
|
|
3227
3246
|
operationContext?: OperationContext;
|
|
3228
3247
|
forwardEvent?: (event: StreamEvent) => Promise<void>;
|
|
3248
|
+
maxSteps?: number;
|
|
3229
3249
|
}, Record<string, any>>): BaseTool;
|
|
3230
3250
|
/**
|
|
3231
3251
|
* Get sub-agent details for API exposure
|
|
@@ -3293,6 +3313,10 @@ declare class Agent<TProvider extends {
|
|
|
3293
3313
|
* Indicates if the agent should format responses using Markdown.
|
|
3294
3314
|
*/
|
|
3295
3315
|
readonly markdown: boolean;
|
|
3316
|
+
/**
|
|
3317
|
+
* Maximum number of steps the agent can take before stopping
|
|
3318
|
+
*/
|
|
3319
|
+
readonly maxSteps?: number;
|
|
3296
3320
|
/**
|
|
3297
3321
|
* Memory manager for the agent
|
|
3298
3322
|
*/
|
|
@@ -3434,6 +3458,10 @@ declare class Agent<TProvider extends {
|
|
|
3434
3458
|
*/
|
|
3435
3459
|
private _endOtelToolSpan;
|
|
3436
3460
|
private publishTimelineEvent;
|
|
3461
|
+
/**
|
|
3462
|
+
* Sets up abort signal listener for cancellation handling
|
|
3463
|
+
*/
|
|
3464
|
+
private setupAbortSignalListener;
|
|
3437
3465
|
/**
|
|
3438
3466
|
* Create an enhanced fullStream with real-time SubAgent event injection
|
|
3439
3467
|
*/
|
package/dist/index.js
CHANGED
|
@@ -325,10 +325,6 @@ var BackgroundQueue = class {
|
|
|
325
325
|
} catch (error) {
|
|
326
326
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
327
327
|
if (attempt < maxAttempts) {
|
|
328
|
-
import_dev.devLogger.warn(
|
|
329
|
-
`[Queue] Task ${task.id} failed (attempt ${attempt}/${maxAttempts}), retrying:`,
|
|
330
|
-
lastError.message
|
|
331
|
-
);
|
|
332
328
|
await new Promise((resolve) => setTimeout(resolve, 50 * attempt));
|
|
333
329
|
} else {
|
|
334
330
|
import_dev.devLogger.error(
|
|
@@ -944,6 +940,10 @@ var GenerateOptionsSchema = import_zod_openapi.z.object({
|
|
|
944
940
|
contextLimit: import_zod_openapi.z.number().int().positive().optional().default(10).openapi({
|
|
945
941
|
description: "Optional limit for conversation history context"
|
|
946
942
|
}),
|
|
943
|
+
maxSteps: import_zod_openapi.z.number().int().positive().optional().openapi({
|
|
944
|
+
description: "Maximum number of steps (turns) for this specific request (overrides agent's maxSteps)",
|
|
945
|
+
example: 5
|
|
946
|
+
}),
|
|
947
947
|
temperature: import_zod_openapi.z.number().min(0).max(1).optional().default(0.7).openapi({ description: "Controls randomness (0-1)" }),
|
|
948
948
|
maxTokens: import_zod_openapi.z.number().int().positive().optional().default(4e3).openapi({ description: "Maximum tokens to generate" }),
|
|
949
949
|
topP: import_zod_openapi.z.number().min(0).max(1).optional().default(1).openapi({
|
|
@@ -1598,6 +1598,10 @@ app.openapi(streamRoute, async (c) => {
|
|
|
1598
1598
|
temperature: 0.7
|
|
1599
1599
|
}
|
|
1600
1600
|
} = c.req.valid("json");
|
|
1601
|
+
const abortController = new AbortController();
|
|
1602
|
+
c.req.raw.signal?.addEventListener("abort", () => {
|
|
1603
|
+
abortController.abort();
|
|
1604
|
+
});
|
|
1601
1605
|
const stream = new ReadableStream({
|
|
1602
1606
|
async start(controller) {
|
|
1603
1607
|
try {
|
|
@@ -1632,7 +1636,9 @@ app.openapi(streamRoute, async (c) => {
|
|
|
1632
1636
|
temperature: options.temperature
|
|
1633
1637
|
// Note: No onError callback needed - tool errors are handled via fullStream
|
|
1634
1638
|
// Stream errors are handled by try/catch blocks around fullStream iteration
|
|
1635
|
-
}
|
|
1639
|
+
},
|
|
1640
|
+
// Pass the abort signal to the agent
|
|
1641
|
+
signal: abortController.signal
|
|
1636
1642
|
};
|
|
1637
1643
|
const response = await agent.streamText(input, processedStreamOptions);
|
|
1638
1644
|
try {
|
|
@@ -1908,6 +1914,11 @@ app.openapi(streamObjectRoute, async (c) => {
|
|
|
1908
1914
|
options = {}
|
|
1909
1915
|
} = c.req.valid("json");
|
|
1910
1916
|
const schemaInZodObject = (0, import_zod_from_json_schema.convertJsonSchemaToZod)(schema);
|
|
1917
|
+
const abortController = new AbortController();
|
|
1918
|
+
c.req.raw.signal?.addEventListener("abort", () => {
|
|
1919
|
+
console.log("\u{1F6D1} API: Client aborted object stream request, stopping agent stream...");
|
|
1920
|
+
abortController.abort();
|
|
1921
|
+
});
|
|
1911
1922
|
const sseStream = new ReadableStream({
|
|
1912
1923
|
async start(controller) {
|
|
1913
1924
|
try {
|
|
@@ -1954,7 +1965,9 @@ app.openapi(streamObjectRoute, async (c) => {
|
|
|
1954
1965
|
safeEnqueue(errorMessage);
|
|
1955
1966
|
safeClose();
|
|
1956
1967
|
}
|
|
1957
|
-
}
|
|
1968
|
+
},
|
|
1969
|
+
// Pass the abort signal to the agent
|
|
1970
|
+
signal: abortController.signal
|
|
1958
1971
|
};
|
|
1959
1972
|
const agentStream = await agent.streamObject(
|
|
1960
1973
|
input,
|
|
@@ -7606,7 +7619,10 @@ var SubAgentManager = class {
|
|
|
7606
7619
|
* Calculate maximum number of steps based on sub-agents
|
|
7607
7620
|
* More sub-agents means more potential steps
|
|
7608
7621
|
*/
|
|
7609
|
-
calculateMaxSteps() {
|
|
7622
|
+
calculateMaxSteps(agentMaxSteps) {
|
|
7623
|
+
if (agentMaxSteps !== void 0) {
|
|
7624
|
+
return agentMaxSteps;
|
|
7625
|
+
}
|
|
7610
7626
|
return this.subAgents.length > 0 ? 10 * this.subAgents.length : 10;
|
|
7611
7627
|
}
|
|
7612
7628
|
/**
|
|
@@ -7672,7 +7688,8 @@ ${agentsMemory || "No previous agent interactions available."}
|
|
|
7672
7688
|
userId,
|
|
7673
7689
|
parentAgentId,
|
|
7674
7690
|
parentHistoryEntryId,
|
|
7675
|
-
parentOperationContext
|
|
7691
|
+
parentOperationContext,
|
|
7692
|
+
maxSteps
|
|
7676
7693
|
} = options;
|
|
7677
7694
|
const context = options.context;
|
|
7678
7695
|
const sourceAgent = options.sourceAgent;
|
|
@@ -7702,7 +7719,11 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7702
7719
|
// @ts-expect-error - bad types
|
|
7703
7720
|
parentAgentId: sourceAgent?.id || parentAgentId,
|
|
7704
7721
|
parentHistoryEntryId,
|
|
7705
|
-
parentOperationContext
|
|
7722
|
+
parentOperationContext,
|
|
7723
|
+
// Pass the abort signal from parent's operation context to subagent
|
|
7724
|
+
signal: parentOperationContext?.signal,
|
|
7725
|
+
// Pass maxSteps from parent to subagent (inherits parent's effective maxSteps)
|
|
7726
|
+
maxSteps
|
|
7706
7727
|
});
|
|
7707
7728
|
let finalText = "";
|
|
7708
7729
|
if (streamResponse.fullStream) {
|
|
@@ -7846,6 +7867,7 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7846
7867
|
parentAgentId,
|
|
7847
7868
|
parentHistoryEntryId,
|
|
7848
7869
|
parentOperationContext,
|
|
7870
|
+
maxSteps,
|
|
7849
7871
|
...restOptions
|
|
7850
7872
|
} = options;
|
|
7851
7873
|
const handoffConversationId = conversationId || crypto.randomUUID();
|
|
@@ -7858,7 +7880,8 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7858
7880
|
conversationId: handoffConversationId,
|
|
7859
7881
|
parentAgentId,
|
|
7860
7882
|
parentHistoryEntryId,
|
|
7861
|
-
parentOperationContext
|
|
7883
|
+
parentOperationContext,
|
|
7884
|
+
maxSteps
|
|
7862
7885
|
});
|
|
7863
7886
|
} catch (error) {
|
|
7864
7887
|
import_dev15.devLogger.error(`Error in handoffToMultiple for agent ${agent.name}:`, error);
|
|
@@ -7885,7 +7908,14 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7885
7908
|
* task to one or more specialized agents
|
|
7886
7909
|
*/
|
|
7887
7910
|
createDelegateTool(options) {
|
|
7888
|
-
const {
|
|
7911
|
+
const {
|
|
7912
|
+
sourceAgent,
|
|
7913
|
+
forwardEvent,
|
|
7914
|
+
operationContext,
|
|
7915
|
+
currentHistoryEntryId,
|
|
7916
|
+
maxSteps,
|
|
7917
|
+
...restOptions
|
|
7918
|
+
} = options;
|
|
7889
7919
|
return createTool({
|
|
7890
7920
|
id: "delegate_task",
|
|
7891
7921
|
name: "delegate_task",
|
|
@@ -7930,6 +7960,8 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7930
7960
|
parentOperationContext: operationContext,
|
|
7931
7961
|
// Pass the real-time event forwarder
|
|
7932
7962
|
forwardEvent,
|
|
7963
|
+
// Pass maxSteps from parent to subagents
|
|
7964
|
+
maxSteps,
|
|
7933
7965
|
...restOptions
|
|
7934
7966
|
});
|
|
7935
7967
|
const structuredResults = results.map((result, index) => {
|
|
@@ -8035,6 +8067,10 @@ var Agent = class {
|
|
|
8035
8067
|
* Indicates if the agent should format responses using Markdown.
|
|
8036
8068
|
*/
|
|
8037
8069
|
markdown;
|
|
8070
|
+
/**
|
|
8071
|
+
* Maximum number of steps the agent can take before stopping
|
|
8072
|
+
*/
|
|
8073
|
+
maxSteps;
|
|
8038
8074
|
/**
|
|
8039
8075
|
* Memory manager for the agent
|
|
8040
8076
|
*/
|
|
@@ -8077,6 +8113,7 @@ var Agent = class {
|
|
|
8077
8113
|
this.retriever = options.retriever;
|
|
8078
8114
|
this.voice = options.voice;
|
|
8079
8115
|
this.markdown = options.markdown ?? false;
|
|
8116
|
+
this.maxSteps = options.maxSteps;
|
|
8080
8117
|
this.voltOpsClient = options.voltOpsClient;
|
|
8081
8118
|
if (options.hooks) {
|
|
8082
8119
|
this.hooks = options.hooks;
|
|
@@ -8329,7 +8366,7 @@ ${retrieverContext}`;
|
|
|
8329
8366
|
* Calculate maximum number of steps based on sub-agents
|
|
8330
8367
|
*/
|
|
8331
8368
|
calculateMaxSteps() {
|
|
8332
|
-
return this.subAgentManager.calculateMaxSteps();
|
|
8369
|
+
return this.subAgentManager.calculateMaxSteps(this.maxSteps);
|
|
8333
8370
|
}
|
|
8334
8371
|
/**
|
|
8335
8372
|
* Prepare common options for text generation
|
|
@@ -8337,6 +8374,7 @@ ${retrieverContext}`;
|
|
|
8337
8374
|
async prepareTextOptions(options = {}) {
|
|
8338
8375
|
const {
|
|
8339
8376
|
tools: dynamicTools,
|
|
8377
|
+
maxSteps: optionsMaxSteps,
|
|
8340
8378
|
historyEntryId,
|
|
8341
8379
|
operationContext,
|
|
8342
8380
|
internalStreamForwarder
|
|
@@ -8414,6 +8452,8 @@ ${retrieverContext}`;
|
|
|
8414
8452
|
operationContext: options.operationContext,
|
|
8415
8453
|
forwardEvent,
|
|
8416
8454
|
// Pass the real-time event forwarder
|
|
8455
|
+
// Pass effective maxSteps (options override or agent default)
|
|
8456
|
+
maxSteps: optionsMaxSteps ?? this.calculateMaxSteps(),
|
|
8417
8457
|
...options
|
|
8418
8458
|
});
|
|
8419
8459
|
const delegateIndex = toolsToUse.findIndex((tool2) => tool2.name === "delegate_task");
|
|
@@ -8425,7 +8465,7 @@ ${retrieverContext}`;
|
|
|
8425
8465
|
}
|
|
8426
8466
|
return {
|
|
8427
8467
|
tools: toolsToUse,
|
|
8428
|
-
maxSteps: this.calculateMaxSteps()
|
|
8468
|
+
maxSteps: optionsMaxSteps ?? this.calculateMaxSteps()
|
|
8429
8469
|
};
|
|
8430
8470
|
}
|
|
8431
8471
|
/**
|
|
@@ -8469,7 +8509,9 @@ ${retrieverContext}`;
|
|
|
8469
8509
|
parentHistoryEntryId: options.parentHistoryEntryId,
|
|
8470
8510
|
otelSpan,
|
|
8471
8511
|
// Use parent's conversationSteps if available (for SubAgents), otherwise create new array
|
|
8472
|
-
conversationSteps: options.parentOperationContext?.conversationSteps || []
|
|
8512
|
+
conversationSteps: options.parentOperationContext?.conversationSteps || [],
|
|
8513
|
+
// Inherit signal from parent context or use provided signal
|
|
8514
|
+
signal: options.parentOperationContext?.signal || options.signal
|
|
8473
8515
|
};
|
|
8474
8516
|
return opContext;
|
|
8475
8517
|
}
|
|
@@ -8603,6 +8645,52 @@ ${retrieverContext}`;
|
|
|
8603
8645
|
parentHistoryEntryId: operationContext.parentHistoryEntryId
|
|
8604
8646
|
});
|
|
8605
8647
|
}
|
|
8648
|
+
/**
|
|
8649
|
+
* Sets up abort signal listener for cancellation handling
|
|
8650
|
+
*/
|
|
8651
|
+
setupAbortSignalListener(signal, operationContext, finalConversationId, agentStartEvent) {
|
|
8652
|
+
if (!signal)
|
|
8653
|
+
return;
|
|
8654
|
+
signal.addEventListener("abort", async () => {
|
|
8655
|
+
this.updateHistoryEntry(operationContext, {
|
|
8656
|
+
status: "cancelled",
|
|
8657
|
+
endTime: /* @__PURE__ */ new Date()
|
|
8658
|
+
});
|
|
8659
|
+
operationContext.isActive = false;
|
|
8660
|
+
const cancellationError = new Error("Operation cancelled by user");
|
|
8661
|
+
cancellationError.name = "AbortError";
|
|
8662
|
+
const agentCancelledEvent = {
|
|
8663
|
+
id: crypto.randomUUID(),
|
|
8664
|
+
name: "agent:cancel",
|
|
8665
|
+
type: "agent",
|
|
8666
|
+
startTime: agentStartEvent.startTime,
|
|
8667
|
+
endTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8668
|
+
level: "INFO",
|
|
8669
|
+
input: null,
|
|
8670
|
+
statusMessage: {
|
|
8671
|
+
message: cancellationError.message,
|
|
8672
|
+
code: "USER_CANCELLED",
|
|
8673
|
+
stage: "cancelled"
|
|
8674
|
+
},
|
|
8675
|
+
status: "cancelled",
|
|
8676
|
+
metadata: {
|
|
8677
|
+
displayName: this.name,
|
|
8678
|
+
id: this.id,
|
|
8679
|
+
userContext: Object.fromEntries(operationContext.userContext.entries())
|
|
8680
|
+
},
|
|
8681
|
+
traceId: operationContext.historyEntry.id,
|
|
8682
|
+
parentEventId: agentStartEvent.id
|
|
8683
|
+
};
|
|
8684
|
+
this.publishTimelineEvent(operationContext, agentCancelledEvent);
|
|
8685
|
+
await this.hooks.onEnd?.({
|
|
8686
|
+
agent: this,
|
|
8687
|
+
output: void 0,
|
|
8688
|
+
error: cancellationError,
|
|
8689
|
+
conversationId: finalConversationId || "",
|
|
8690
|
+
context: operationContext
|
|
8691
|
+
});
|
|
8692
|
+
});
|
|
8693
|
+
}
|
|
8606
8694
|
/**
|
|
8607
8695
|
* Create an enhanced fullStream with real-time SubAgent event injection
|
|
8608
8696
|
*/
|
|
@@ -8659,7 +8747,8 @@ ${retrieverContext}`;
|
|
|
8659
8747
|
parentHistoryEntryId,
|
|
8660
8748
|
parentOperationContext,
|
|
8661
8749
|
contextLimit = 10,
|
|
8662
|
-
userContext
|
|
8750
|
+
userContext,
|
|
8751
|
+
signal
|
|
8663
8752
|
} = internalOptions;
|
|
8664
8753
|
const operationContext = await this.initializeHistory(input, "working", {
|
|
8665
8754
|
parentAgentId,
|
|
@@ -8668,7 +8757,8 @@ ${retrieverContext}`;
|
|
|
8668
8757
|
userContext,
|
|
8669
8758
|
userId,
|
|
8670
8759
|
conversationId: initialConversationId,
|
|
8671
|
-
parentOperationContext
|
|
8760
|
+
parentOperationContext,
|
|
8761
|
+
signal
|
|
8672
8762
|
});
|
|
8673
8763
|
const { messages: contextMessages, conversationId: finalConversationId } = await this.memoryManager.prepareConversationContext(
|
|
8674
8764
|
operationContext,
|
|
@@ -8719,7 +8809,8 @@ ${retrieverContext}`;
|
|
|
8719
8809
|
temperature: internalOptions.provider?.temperature,
|
|
8720
8810
|
topP: internalOptions.provider?.topP,
|
|
8721
8811
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
8722
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
8812
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
8813
|
+
maxSteps: internalOptions.maxSteps
|
|
8723
8814
|
}
|
|
8724
8815
|
},
|
|
8725
8816
|
traceId: operationContext.historyEntry.id
|
|
@@ -8727,6 +8818,10 @@ ${retrieverContext}`;
|
|
|
8727
8818
|
operationContext.userContext.set("agent_start_time", agentStartTime);
|
|
8728
8819
|
operationContext.userContext.set("agent_start_event_id", agentStartEvent.id);
|
|
8729
8820
|
this.publishTimelineEvent(operationContext, agentStartEvent);
|
|
8821
|
+
this.setupAbortSignalListener(signal, operationContext, finalConversationId, {
|
|
8822
|
+
id: agentStartEvent.id,
|
|
8823
|
+
startTime: agentStartTime
|
|
8824
|
+
});
|
|
8730
8825
|
const onStepFinish = this.memoryManager.createStepFinishHandler(
|
|
8731
8826
|
operationContext,
|
|
8732
8827
|
userId,
|
|
@@ -8840,7 +8935,7 @@ ${retrieverContext}`;
|
|
|
8840
8935
|
id: crypto.randomUUID(),
|
|
8841
8936
|
name: "tool:success",
|
|
8842
8937
|
type: "tool",
|
|
8843
|
-
startTime:
|
|
8938
|
+
startTime: toolStartInfo.startTime,
|
|
8844
8939
|
// Use the original start time
|
|
8845
8940
|
endTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8846
8941
|
// Current time as end time
|
|
@@ -8904,7 +8999,8 @@ ${retrieverContext}`;
|
|
|
8904
8999
|
temperature: internalOptions.provider?.temperature,
|
|
8905
9000
|
topP: internalOptions.provider?.topP,
|
|
8906
9001
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
8907
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9002
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9003
|
+
maxSteps: internalOptions.maxSteps
|
|
8908
9004
|
}
|
|
8909
9005
|
},
|
|
8910
9006
|
traceId: operationContext.historyEntry.id,
|
|
@@ -9015,7 +9111,8 @@ ${retrieverContext}`;
|
|
|
9015
9111
|
parentHistoryEntryId,
|
|
9016
9112
|
parentOperationContext,
|
|
9017
9113
|
contextLimit = 10,
|
|
9018
|
-
userContext
|
|
9114
|
+
userContext,
|
|
9115
|
+
signal
|
|
9019
9116
|
} = internalOptions;
|
|
9020
9117
|
const operationContext = await this.initializeHistory(input, "working", {
|
|
9021
9118
|
parentAgentId,
|
|
@@ -9024,7 +9121,8 @@ ${retrieverContext}`;
|
|
|
9024
9121
|
userContext,
|
|
9025
9122
|
userId,
|
|
9026
9123
|
conversationId: initialConversationId,
|
|
9027
|
-
parentOperationContext
|
|
9124
|
+
parentOperationContext,
|
|
9125
|
+
signal
|
|
9028
9126
|
});
|
|
9029
9127
|
const { messages: contextMessages, conversationId: finalConversationId } = await this.memoryManager.prepareConversationContext(
|
|
9030
9128
|
operationContext,
|
|
@@ -9073,7 +9171,8 @@ ${retrieverContext}`;
|
|
|
9073
9171
|
temperature: internalOptions.provider?.temperature,
|
|
9074
9172
|
topP: internalOptions.provider?.topP,
|
|
9075
9173
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9076
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9174
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9175
|
+
maxSteps: internalOptions.maxSteps
|
|
9077
9176
|
}
|
|
9078
9177
|
},
|
|
9079
9178
|
traceId: operationContext.historyEntry.id
|
|
@@ -9081,6 +9180,10 @@ ${retrieverContext}`;
|
|
|
9081
9180
|
operationContext.userContext.set("agent_start_time", agentStartTime);
|
|
9082
9181
|
operationContext.userContext.set("agent_start_event_id", agentStartEvent.id);
|
|
9083
9182
|
this.publishTimelineEvent(operationContext, agentStartEvent);
|
|
9183
|
+
this.setupAbortSignalListener(signal, operationContext, finalConversationId, {
|
|
9184
|
+
id: agentStartEvent.id,
|
|
9185
|
+
startTime: agentStartTime
|
|
9186
|
+
});
|
|
9084
9187
|
const onStepFinish = this.memoryManager.createStepFinishHandler(
|
|
9085
9188
|
operationContext,
|
|
9086
9189
|
userId,
|
|
@@ -9201,7 +9304,7 @@ ${retrieverContext}`;
|
|
|
9201
9304
|
id: crypto.randomUUID(),
|
|
9202
9305
|
name: "tool:error",
|
|
9203
9306
|
type: "tool",
|
|
9204
|
-
startTime:
|
|
9307
|
+
startTime: toolStartInfo.startTime,
|
|
9205
9308
|
// Use the original start time
|
|
9206
9309
|
endTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9207
9310
|
// Current time as end time
|
|
@@ -9225,7 +9328,7 @@ ${retrieverContext}`;
|
|
|
9225
9328
|
id: crypto.randomUUID(),
|
|
9226
9329
|
name: "tool:success",
|
|
9227
9330
|
type: "tool",
|
|
9228
|
-
startTime:
|
|
9331
|
+
startTime: toolStartInfo.startTime,
|
|
9229
9332
|
// Use the original start time
|
|
9230
9333
|
endTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9231
9334
|
// Current time as end time
|
|
@@ -9306,7 +9409,8 @@ ${retrieverContext}`;
|
|
|
9306
9409
|
temperature: internalOptions.provider?.temperature,
|
|
9307
9410
|
topP: internalOptions.provider?.topP,
|
|
9308
9411
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9309
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9412
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9413
|
+
maxSteps: internalOptions.maxSteps
|
|
9310
9414
|
}
|
|
9311
9415
|
},
|
|
9312
9416
|
traceId: operationContext.historyEntry.id,
|
|
@@ -9356,7 +9460,7 @@ ${retrieverContext}`;
|
|
|
9356
9460
|
id: crypto.randomUUID(),
|
|
9357
9461
|
name: "tool:error",
|
|
9358
9462
|
type: "tool",
|
|
9359
|
-
startTime:
|
|
9463
|
+
startTime: toolStartInfo.startTime,
|
|
9360
9464
|
endTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9361
9465
|
status: "error",
|
|
9362
9466
|
level: "ERROR",
|
|
@@ -9474,7 +9578,8 @@ ${retrieverContext}`;
|
|
|
9474
9578
|
parentHistoryEntryId,
|
|
9475
9579
|
parentOperationContext,
|
|
9476
9580
|
contextLimit = 10,
|
|
9477
|
-
userContext
|
|
9581
|
+
userContext,
|
|
9582
|
+
signal
|
|
9478
9583
|
} = internalOptions;
|
|
9479
9584
|
const operationContext = await this.initializeHistory(input, "working", {
|
|
9480
9585
|
parentAgentId,
|
|
@@ -9483,7 +9588,8 @@ ${retrieverContext}`;
|
|
|
9483
9588
|
userContext,
|
|
9484
9589
|
userId,
|
|
9485
9590
|
conversationId: initialConversationId,
|
|
9486
|
-
parentOperationContext
|
|
9591
|
+
parentOperationContext,
|
|
9592
|
+
signal
|
|
9487
9593
|
});
|
|
9488
9594
|
const { messages: contextMessages, conversationId: finalConversationId } = await this.memoryManager.prepareConversationContext(
|
|
9489
9595
|
operationContext,
|
|
@@ -9534,7 +9640,8 @@ ${retrieverContext}`;
|
|
|
9534
9640
|
temperature: internalOptions.provider?.temperature,
|
|
9535
9641
|
topP: internalOptions.provider?.topP,
|
|
9536
9642
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9537
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9643
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9644
|
+
maxSteps: internalOptions.maxSteps
|
|
9538
9645
|
}
|
|
9539
9646
|
},
|
|
9540
9647
|
traceId: operationContext.historyEntry.id
|
|
@@ -9542,6 +9649,10 @@ ${retrieverContext}`;
|
|
|
9542
9649
|
operationContext.userContext.set("agent_start_time", agentStartTime);
|
|
9543
9650
|
operationContext.userContext.set("agent_start_event_id", agentStartEvent.id);
|
|
9544
9651
|
this.publishTimelineEvent(operationContext, agentStartEvent);
|
|
9652
|
+
this.setupAbortSignalListener(signal, operationContext, finalConversationId, {
|
|
9653
|
+
id: agentStartEvent.id,
|
|
9654
|
+
startTime: agentStartTime
|
|
9655
|
+
});
|
|
9545
9656
|
const onStepFinish = this.memoryManager.createStepFinishHandler(
|
|
9546
9657
|
operationContext,
|
|
9547
9658
|
userId,
|
|
@@ -9603,7 +9714,8 @@ ${retrieverContext}`;
|
|
|
9603
9714
|
temperature: internalOptions.provider?.temperature,
|
|
9604
9715
|
topP: internalOptions.provider?.topP,
|
|
9605
9716
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9606
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9717
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9718
|
+
maxSteps: internalOptions.maxSteps
|
|
9607
9719
|
}
|
|
9608
9720
|
},
|
|
9609
9721
|
traceId: operationContext.historyEntry.id,
|
|
@@ -9716,7 +9828,8 @@ ${retrieverContext}`;
|
|
|
9716
9828
|
parentOperationContext,
|
|
9717
9829
|
provider,
|
|
9718
9830
|
contextLimit = 10,
|
|
9719
|
-
userContext
|
|
9831
|
+
userContext,
|
|
9832
|
+
signal
|
|
9720
9833
|
} = internalOptions;
|
|
9721
9834
|
const operationContext = await this.initializeHistory(input, "working", {
|
|
9722
9835
|
parentAgentId,
|
|
@@ -9725,7 +9838,8 @@ ${retrieverContext}`;
|
|
|
9725
9838
|
userContext,
|
|
9726
9839
|
userId,
|
|
9727
9840
|
conversationId: initialConversationId,
|
|
9728
|
-
parentOperationContext
|
|
9841
|
+
parentOperationContext,
|
|
9842
|
+
signal
|
|
9729
9843
|
});
|
|
9730
9844
|
const { messages: contextMessages, conversationId: finalConversationId } = await this.memoryManager.prepareConversationContext(
|
|
9731
9845
|
operationContext,
|
|
@@ -9774,7 +9888,8 @@ ${retrieverContext}`;
|
|
|
9774
9888
|
temperature: internalOptions.provider?.temperature,
|
|
9775
9889
|
topP: internalOptions.provider?.topP,
|
|
9776
9890
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9777
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9891
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9892
|
+
maxSteps: internalOptions.maxSteps
|
|
9778
9893
|
}
|
|
9779
9894
|
},
|
|
9780
9895
|
traceId: operationContext.historyEntry.id
|
|
@@ -9782,6 +9897,10 @@ ${retrieverContext}`;
|
|
|
9782
9897
|
operationContext.userContext.set("agent_start_time", agentStartTime);
|
|
9783
9898
|
operationContext.userContext.set("agent_start_event_id", agentStartEvent.id);
|
|
9784
9899
|
this.publishTimelineEvent(operationContext, agentStartEvent);
|
|
9900
|
+
this.setupAbortSignalListener(signal, operationContext, finalConversationId, {
|
|
9901
|
+
id: agentStartEvent.id,
|
|
9902
|
+
startTime: agentStartTime
|
|
9903
|
+
});
|
|
9785
9904
|
const onStepFinish = this.memoryManager.createStepFinishHandler(
|
|
9786
9905
|
operationContext,
|
|
9787
9906
|
userId,
|
|
@@ -9847,7 +9966,8 @@ ${retrieverContext}`;
|
|
|
9847
9966
|
temperature: internalOptions.provider?.temperature,
|
|
9848
9967
|
topP: internalOptions.provider?.topP,
|
|
9849
9968
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9850
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9969
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9970
|
+
maxSteps: internalOptions.maxSteps
|
|
9851
9971
|
}
|
|
9852
9972
|
},
|
|
9853
9973
|
traceId: operationContext.historyEntry.id,
|