@voltagent/core 0.1.51 → 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 +19 -1
- package/dist/index.js +52 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -19
- 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;
|
|
@@ -1326,6 +1332,11 @@ type AgentHandoffOptions = {
|
|
|
1326
1332
|
* AbortSignal to cancel the handoff operation
|
|
1327
1333
|
*/
|
|
1328
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;
|
|
1329
1340
|
};
|
|
1330
1341
|
/**
|
|
1331
1342
|
* Result of a handoff to another agent
|
|
@@ -2000,6 +2011,7 @@ type AgentStartEventMetadata = {
|
|
|
2000
2011
|
stop?: string[];
|
|
2001
2012
|
system?: string;
|
|
2002
2013
|
toolChoice?: string;
|
|
2014
|
+
maxSteps?: number;
|
|
2003
2015
|
};
|
|
2004
2016
|
systemPrompt?: string | BaseMessage | BaseMessage[];
|
|
2005
2017
|
messages?: BaseMessage[];
|
|
@@ -2016,6 +2028,7 @@ interface AgentSuccessEventMetadata extends BaseEventMetadata {
|
|
|
2016
2028
|
stop?: string[];
|
|
2017
2029
|
system?: string;
|
|
2018
2030
|
toolChoice?: string;
|
|
2031
|
+
maxSteps?: number;
|
|
2019
2032
|
};
|
|
2020
2033
|
}
|
|
2021
2034
|
interface MemoryEventMetadata extends BaseEventMetadata {
|
|
@@ -3202,7 +3215,7 @@ declare class SubAgentManager {
|
|
|
3202
3215
|
* Calculate maximum number of steps based on sub-agents
|
|
3203
3216
|
* More sub-agents means more potential steps
|
|
3204
3217
|
*/
|
|
3205
|
-
calculateMaxSteps(): number;
|
|
3218
|
+
calculateMaxSteps(agentMaxSteps?: number): number;
|
|
3206
3219
|
/**
|
|
3207
3220
|
* Generate enhanced system message for supervisor role
|
|
3208
3221
|
* @param baseDescription - The base description of the agent
|
|
@@ -3232,6 +3245,7 @@ declare class SubAgentManager {
|
|
|
3232
3245
|
currentHistoryEntryId?: string;
|
|
3233
3246
|
operationContext?: OperationContext;
|
|
3234
3247
|
forwardEvent?: (event: StreamEvent) => Promise<void>;
|
|
3248
|
+
maxSteps?: number;
|
|
3235
3249
|
}, Record<string, any>>): BaseTool;
|
|
3236
3250
|
/**
|
|
3237
3251
|
* Get sub-agent details for API exposure
|
|
@@ -3299,6 +3313,10 @@ declare class Agent<TProvider extends {
|
|
|
3299
3313
|
* Indicates if the agent should format responses using Markdown.
|
|
3300
3314
|
*/
|
|
3301
3315
|
readonly markdown: boolean;
|
|
3316
|
+
/**
|
|
3317
|
+
* Maximum number of steps the agent can take before stopping
|
|
3318
|
+
*/
|
|
3319
|
+
readonly maxSteps?: number;
|
|
3302
3320
|
/**
|
|
3303
3321
|
* Memory manager for the agent
|
|
3304
3322
|
*/
|
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({
|
|
@@ -7619,7 +7619,10 @@ var SubAgentManager = class {
|
|
|
7619
7619
|
* Calculate maximum number of steps based on sub-agents
|
|
7620
7620
|
* More sub-agents means more potential steps
|
|
7621
7621
|
*/
|
|
7622
|
-
calculateMaxSteps() {
|
|
7622
|
+
calculateMaxSteps(agentMaxSteps) {
|
|
7623
|
+
if (agentMaxSteps !== void 0) {
|
|
7624
|
+
return agentMaxSteps;
|
|
7625
|
+
}
|
|
7623
7626
|
return this.subAgents.length > 0 ? 10 * this.subAgents.length : 10;
|
|
7624
7627
|
}
|
|
7625
7628
|
/**
|
|
@@ -7685,7 +7688,8 @@ ${agentsMemory || "No previous agent interactions available."}
|
|
|
7685
7688
|
userId,
|
|
7686
7689
|
parentAgentId,
|
|
7687
7690
|
parentHistoryEntryId,
|
|
7688
|
-
parentOperationContext
|
|
7691
|
+
parentOperationContext,
|
|
7692
|
+
maxSteps
|
|
7689
7693
|
} = options;
|
|
7690
7694
|
const context = options.context;
|
|
7691
7695
|
const sourceAgent = options.sourceAgent;
|
|
@@ -7717,7 +7721,9 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7717
7721
|
parentHistoryEntryId,
|
|
7718
7722
|
parentOperationContext,
|
|
7719
7723
|
// Pass the abort signal from parent's operation context to subagent
|
|
7720
|
-
signal: parentOperationContext?.signal
|
|
7724
|
+
signal: parentOperationContext?.signal,
|
|
7725
|
+
// Pass maxSteps from parent to subagent (inherits parent's effective maxSteps)
|
|
7726
|
+
maxSteps
|
|
7721
7727
|
});
|
|
7722
7728
|
let finalText = "";
|
|
7723
7729
|
if (streamResponse.fullStream) {
|
|
@@ -7861,6 +7867,7 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7861
7867
|
parentAgentId,
|
|
7862
7868
|
parentHistoryEntryId,
|
|
7863
7869
|
parentOperationContext,
|
|
7870
|
+
maxSteps,
|
|
7864
7871
|
...restOptions
|
|
7865
7872
|
} = options;
|
|
7866
7873
|
const handoffConversationId = conversationId || crypto.randomUUID();
|
|
@@ -7873,7 +7880,8 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7873
7880
|
conversationId: handoffConversationId,
|
|
7874
7881
|
parentAgentId,
|
|
7875
7882
|
parentHistoryEntryId,
|
|
7876
|
-
parentOperationContext
|
|
7883
|
+
parentOperationContext,
|
|
7884
|
+
maxSteps
|
|
7877
7885
|
});
|
|
7878
7886
|
} catch (error) {
|
|
7879
7887
|
import_dev15.devLogger.error(`Error in handoffToMultiple for agent ${agent.name}:`, error);
|
|
@@ -7900,7 +7908,14 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7900
7908
|
* task to one or more specialized agents
|
|
7901
7909
|
*/
|
|
7902
7910
|
createDelegateTool(options) {
|
|
7903
|
-
const {
|
|
7911
|
+
const {
|
|
7912
|
+
sourceAgent,
|
|
7913
|
+
forwardEvent,
|
|
7914
|
+
operationContext,
|
|
7915
|
+
currentHistoryEntryId,
|
|
7916
|
+
maxSteps,
|
|
7917
|
+
...restOptions
|
|
7918
|
+
} = options;
|
|
7904
7919
|
return createTool({
|
|
7905
7920
|
id: "delegate_task",
|
|
7906
7921
|
name: "delegate_task",
|
|
@@ -7945,6 +7960,8 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
7945
7960
|
parentOperationContext: operationContext,
|
|
7946
7961
|
// Pass the real-time event forwarder
|
|
7947
7962
|
forwardEvent,
|
|
7963
|
+
// Pass maxSteps from parent to subagents
|
|
7964
|
+
maxSteps,
|
|
7948
7965
|
...restOptions
|
|
7949
7966
|
});
|
|
7950
7967
|
const structuredResults = results.map((result, index) => {
|
|
@@ -8050,6 +8067,10 @@ var Agent = class {
|
|
|
8050
8067
|
* Indicates if the agent should format responses using Markdown.
|
|
8051
8068
|
*/
|
|
8052
8069
|
markdown;
|
|
8070
|
+
/**
|
|
8071
|
+
* Maximum number of steps the agent can take before stopping
|
|
8072
|
+
*/
|
|
8073
|
+
maxSteps;
|
|
8053
8074
|
/**
|
|
8054
8075
|
* Memory manager for the agent
|
|
8055
8076
|
*/
|
|
@@ -8092,6 +8113,7 @@ var Agent = class {
|
|
|
8092
8113
|
this.retriever = options.retriever;
|
|
8093
8114
|
this.voice = options.voice;
|
|
8094
8115
|
this.markdown = options.markdown ?? false;
|
|
8116
|
+
this.maxSteps = options.maxSteps;
|
|
8095
8117
|
this.voltOpsClient = options.voltOpsClient;
|
|
8096
8118
|
if (options.hooks) {
|
|
8097
8119
|
this.hooks = options.hooks;
|
|
@@ -8344,7 +8366,7 @@ ${retrieverContext}`;
|
|
|
8344
8366
|
* Calculate maximum number of steps based on sub-agents
|
|
8345
8367
|
*/
|
|
8346
8368
|
calculateMaxSteps() {
|
|
8347
|
-
return this.subAgentManager.calculateMaxSteps();
|
|
8369
|
+
return this.subAgentManager.calculateMaxSteps(this.maxSteps);
|
|
8348
8370
|
}
|
|
8349
8371
|
/**
|
|
8350
8372
|
* Prepare common options for text generation
|
|
@@ -8352,6 +8374,7 @@ ${retrieverContext}`;
|
|
|
8352
8374
|
async prepareTextOptions(options = {}) {
|
|
8353
8375
|
const {
|
|
8354
8376
|
tools: dynamicTools,
|
|
8377
|
+
maxSteps: optionsMaxSteps,
|
|
8355
8378
|
historyEntryId,
|
|
8356
8379
|
operationContext,
|
|
8357
8380
|
internalStreamForwarder
|
|
@@ -8429,6 +8452,8 @@ ${retrieverContext}`;
|
|
|
8429
8452
|
operationContext: options.operationContext,
|
|
8430
8453
|
forwardEvent,
|
|
8431
8454
|
// Pass the real-time event forwarder
|
|
8455
|
+
// Pass effective maxSteps (options override or agent default)
|
|
8456
|
+
maxSteps: optionsMaxSteps ?? this.calculateMaxSteps(),
|
|
8432
8457
|
...options
|
|
8433
8458
|
});
|
|
8434
8459
|
const delegateIndex = toolsToUse.findIndex((tool2) => tool2.name === "delegate_task");
|
|
@@ -8440,7 +8465,7 @@ ${retrieverContext}`;
|
|
|
8440
8465
|
}
|
|
8441
8466
|
return {
|
|
8442
8467
|
tools: toolsToUse,
|
|
8443
|
-
maxSteps: this.calculateMaxSteps()
|
|
8468
|
+
maxSteps: optionsMaxSteps ?? this.calculateMaxSteps()
|
|
8444
8469
|
};
|
|
8445
8470
|
}
|
|
8446
8471
|
/**
|
|
@@ -8784,7 +8809,8 @@ ${retrieverContext}`;
|
|
|
8784
8809
|
temperature: internalOptions.provider?.temperature,
|
|
8785
8810
|
topP: internalOptions.provider?.topP,
|
|
8786
8811
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
8787
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
8812
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
8813
|
+
maxSteps: internalOptions.maxSteps
|
|
8788
8814
|
}
|
|
8789
8815
|
},
|
|
8790
8816
|
traceId: operationContext.historyEntry.id
|
|
@@ -8973,7 +8999,8 @@ ${retrieverContext}`;
|
|
|
8973
8999
|
temperature: internalOptions.provider?.temperature,
|
|
8974
9000
|
topP: internalOptions.provider?.topP,
|
|
8975
9001
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
8976
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9002
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9003
|
+
maxSteps: internalOptions.maxSteps
|
|
8977
9004
|
}
|
|
8978
9005
|
},
|
|
8979
9006
|
traceId: operationContext.historyEntry.id,
|
|
@@ -9144,7 +9171,8 @@ ${retrieverContext}`;
|
|
|
9144
9171
|
temperature: internalOptions.provider?.temperature,
|
|
9145
9172
|
topP: internalOptions.provider?.topP,
|
|
9146
9173
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9147
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9174
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9175
|
+
maxSteps: internalOptions.maxSteps
|
|
9148
9176
|
}
|
|
9149
9177
|
},
|
|
9150
9178
|
traceId: operationContext.historyEntry.id
|
|
@@ -9381,7 +9409,8 @@ ${retrieverContext}`;
|
|
|
9381
9409
|
temperature: internalOptions.provider?.temperature,
|
|
9382
9410
|
topP: internalOptions.provider?.topP,
|
|
9383
9411
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9384
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9412
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9413
|
+
maxSteps: internalOptions.maxSteps
|
|
9385
9414
|
}
|
|
9386
9415
|
},
|
|
9387
9416
|
traceId: operationContext.historyEntry.id,
|
|
@@ -9611,7 +9640,8 @@ ${retrieverContext}`;
|
|
|
9611
9640
|
temperature: internalOptions.provider?.temperature,
|
|
9612
9641
|
topP: internalOptions.provider?.topP,
|
|
9613
9642
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9614
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9643
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9644
|
+
maxSteps: internalOptions.maxSteps
|
|
9615
9645
|
}
|
|
9616
9646
|
},
|
|
9617
9647
|
traceId: operationContext.historyEntry.id
|
|
@@ -9684,7 +9714,8 @@ ${retrieverContext}`;
|
|
|
9684
9714
|
temperature: internalOptions.provider?.temperature,
|
|
9685
9715
|
topP: internalOptions.provider?.topP,
|
|
9686
9716
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9687
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9717
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9718
|
+
maxSteps: internalOptions.maxSteps
|
|
9688
9719
|
}
|
|
9689
9720
|
},
|
|
9690
9721
|
traceId: operationContext.historyEntry.id,
|
|
@@ -9857,7 +9888,8 @@ ${retrieverContext}`;
|
|
|
9857
9888
|
temperature: internalOptions.provider?.temperature,
|
|
9858
9889
|
topP: internalOptions.provider?.topP,
|
|
9859
9890
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9860
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9891
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9892
|
+
maxSteps: internalOptions.maxSteps
|
|
9861
9893
|
}
|
|
9862
9894
|
},
|
|
9863
9895
|
traceId: operationContext.historyEntry.id
|
|
@@ -9934,7 +9966,8 @@ ${retrieverContext}`;
|
|
|
9934
9966
|
temperature: internalOptions.provider?.temperature,
|
|
9935
9967
|
topP: internalOptions.provider?.topP,
|
|
9936
9968
|
frequencyPenalty: internalOptions.provider?.frequencyPenalty,
|
|
9937
|
-
presencePenalty: internalOptions.provider?.presencePenalty
|
|
9969
|
+
presencePenalty: internalOptions.provider?.presencePenalty,
|
|
9970
|
+
maxSteps: internalOptions.maxSteps
|
|
9938
9971
|
}
|
|
9939
9972
|
},
|
|
9940
9973
|
traceId: operationContext.historyEntry.id,
|