@voltagent/core 0.1.13 → 0.1.14
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/README.md +1 -1
- package/dist/index.d.ts +30 -8
- package/dist/index.js +20 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,7 +100,7 @@ import { openai } from "@ai-sdk/openai"; // Example model
|
|
|
100
100
|
// Define a simple agent
|
|
101
101
|
const agent = new Agent({
|
|
102
102
|
name: "my-agent",
|
|
103
|
-
|
|
103
|
+
instructions: "A helpful assistant that answers questions without using tools",
|
|
104
104
|
// Note: You can swap VercelAIProvider and openai with other supported providers/models
|
|
105
105
|
llm: new VercelAIProvider(),
|
|
106
106
|
model: openai("gpt-4o-mini"),
|
package/dist/index.d.ts
CHANGED
|
@@ -440,10 +440,6 @@ type AgentOptions = {
|
|
|
440
440
|
* Agent name
|
|
441
441
|
*/
|
|
442
442
|
name: string;
|
|
443
|
-
/**
|
|
444
|
-
* Agent description
|
|
445
|
-
*/
|
|
446
|
-
description?: string;
|
|
447
443
|
/**
|
|
448
444
|
* Memory storage for the agent (optional)
|
|
449
445
|
* Set to false to explicitly disable memory
|
|
@@ -461,7 +457,28 @@ type AgentOptions = {
|
|
|
461
457
|
* Sub-agents that this agent can delegate tasks to
|
|
462
458
|
*/
|
|
463
459
|
subAgents?: any[];
|
|
464
|
-
}
|
|
460
|
+
} & ({
|
|
461
|
+
/**
|
|
462
|
+
* @deprecated Use `instructions` instead.
|
|
463
|
+
* Agent description (deprecated, use instructions)
|
|
464
|
+
*/
|
|
465
|
+
description: string;
|
|
466
|
+
/**
|
|
467
|
+
* Agent instructions. This is the preferred field.
|
|
468
|
+
*/
|
|
469
|
+
instructions?: string;
|
|
470
|
+
} | {
|
|
471
|
+
/**
|
|
472
|
+
* @deprecated Use `instructions` instead.
|
|
473
|
+
* Agent description (deprecated, use instructions)
|
|
474
|
+
*/
|
|
475
|
+
description?: undefined;
|
|
476
|
+
/**
|
|
477
|
+
* Agent instructions. This is the preferred field.
|
|
478
|
+
* Required if description is not provided.
|
|
479
|
+
*/
|
|
480
|
+
instructions: string;
|
|
481
|
+
});
|
|
465
482
|
/**
|
|
466
483
|
* Provider instance type helper
|
|
467
484
|
*/
|
|
@@ -1774,7 +1791,7 @@ declare class SubAgentManager {
|
|
|
1774
1791
|
* @param baseDescription - The base description of the agent
|
|
1775
1792
|
* @param agentsMemory - Optional string containing formatted memory from previous agent interactions
|
|
1776
1793
|
*/
|
|
1777
|
-
generateSupervisorSystemMessage(
|
|
1794
|
+
generateSupervisorSystemMessage(baseInstructions: string, agentsMemory?: string): string;
|
|
1778
1795
|
/**
|
|
1779
1796
|
* Check if the agent has sub-agents
|
|
1780
1797
|
*/
|
|
@@ -2008,9 +2025,13 @@ declare class Agent<TProvider extends {
|
|
|
2008
2025
|
*/
|
|
2009
2026
|
readonly name: string;
|
|
2010
2027
|
/**
|
|
2011
|
-
*
|
|
2028
|
+
* @deprecated Use `instructions` instead. Will be removed in a future version.
|
|
2012
2029
|
*/
|
|
2013
2030
|
readonly description: string;
|
|
2031
|
+
/**
|
|
2032
|
+
* Agent instructions. This is the preferred field over `description`.
|
|
2033
|
+
*/
|
|
2034
|
+
readonly instructions: string;
|
|
2014
2035
|
/**
|
|
2015
2036
|
* The LLM provider to use
|
|
2016
2037
|
*/
|
|
@@ -2054,7 +2075,7 @@ declare class Agent<TProvider extends {
|
|
|
2054
2075
|
/**
|
|
2055
2076
|
* Create a new agent
|
|
2056
2077
|
*/
|
|
2057
|
-
constructor(options:
|
|
2078
|
+
constructor(options: AgentOptions & TProvider & {
|
|
2058
2079
|
model: ModelType<TProvider>;
|
|
2059
2080
|
subAgents?: Agent<any>[];
|
|
2060
2081
|
maxHistoryEntries?: number;
|
|
@@ -2103,6 +2124,7 @@ declare class Agent<TProvider extends {
|
|
|
2103
2124
|
id: string;
|
|
2104
2125
|
name: string;
|
|
2105
2126
|
description: string;
|
|
2127
|
+
instructions: string;
|
|
2106
2128
|
status: string;
|
|
2107
2129
|
model: string;
|
|
2108
2130
|
node_id: string;
|
package/dist/index.js
CHANGED
|
@@ -4318,11 +4318,11 @@ var SubAgentManager = class {
|
|
|
4318
4318
|
* @param baseDescription - The base description of the agent
|
|
4319
4319
|
* @param agentsMemory - Optional string containing formatted memory from previous agent interactions
|
|
4320
4320
|
*/
|
|
4321
|
-
generateSupervisorSystemMessage(
|
|
4321
|
+
generateSupervisorSystemMessage(baseInstructions, agentsMemory = "") {
|
|
4322
4322
|
if (this.subAgents.length === 0) {
|
|
4323
|
-
return
|
|
4323
|
+
return baseInstructions;
|
|
4324
4324
|
}
|
|
4325
|
-
const subAgentList = this.subAgents.map((agent) => `- ${agent.name}: ${agent.
|
|
4325
|
+
const subAgentList = this.subAgents.map((agent) => `- ${agent.name}: ${agent.instructions}`).join("\n");
|
|
4326
4326
|
return `
|
|
4327
4327
|
You are a supervisor agent that coordinates between specialized agents:
|
|
4328
4328
|
|
|
@@ -4331,7 +4331,7 @@ ${subAgentList}
|
|
|
4331
4331
|
</specialized_agents>
|
|
4332
4332
|
|
|
4333
4333
|
<instructions>
|
|
4334
|
-
${
|
|
4334
|
+
${baseInstructions}
|
|
4335
4335
|
</instructions>
|
|
4336
4336
|
|
|
4337
4337
|
<guidelines>
|
|
@@ -4905,15 +4905,16 @@ var Agent = class {
|
|
|
4905
4905
|
context
|
|
4906
4906
|
);
|
|
4907
4907
|
}, "addAgentEvent");
|
|
4908
|
-
var _a;
|
|
4908
|
+
var _a, _b, _c;
|
|
4909
4909
|
this.id = options.id || options.name;
|
|
4910
4910
|
this.name = options.name;
|
|
4911
|
-
this.
|
|
4911
|
+
this.instructions = (_b = (_a = options.instructions) != null ? _a : options.description) != null ? _b : "A helpful AI assistant";
|
|
4912
|
+
this.description = this.instructions;
|
|
4912
4913
|
this.llm = options.llm;
|
|
4913
4914
|
this.model = options.model;
|
|
4914
4915
|
this.retriever = options.retriever;
|
|
4915
4916
|
this.voice = options.voice;
|
|
4916
|
-
this.markdown = (
|
|
4917
|
+
this.markdown = (_c = options.markdown) != null ? _c : false;
|
|
4917
4918
|
if (options.hooks) {
|
|
4918
4919
|
this.hooks = options.hooks;
|
|
4919
4920
|
} else {
|
|
@@ -4937,7 +4938,7 @@ var Agent = class {
|
|
|
4937
4938
|
historyEntryId,
|
|
4938
4939
|
contextMessages
|
|
4939
4940
|
}) {
|
|
4940
|
-
let
|
|
4941
|
+
let baseInstructions = this.instructions || "";
|
|
4941
4942
|
let toolInstructions = "";
|
|
4942
4943
|
const toolkits = this.toolManager.getToolkits();
|
|
4943
4944
|
for (const toolkit of toolkits) {
|
|
@@ -4948,14 +4949,14 @@ ${toolkit.instructions}`;
|
|
|
4948
4949
|
}
|
|
4949
4950
|
}
|
|
4950
4951
|
if (toolInstructions) {
|
|
4951
|
-
|
|
4952
|
+
baseInstructions = `${baseInstructions}${toolInstructions}`;
|
|
4952
4953
|
}
|
|
4953
4954
|
if (this.markdown) {
|
|
4954
|
-
|
|
4955
|
+
baseInstructions = `${baseInstructions}
|
|
4955
4956
|
|
|
4956
4957
|
Use markdown to format your answers.`;
|
|
4957
4958
|
}
|
|
4958
|
-
let
|
|
4959
|
+
let finalInstructions = baseInstructions;
|
|
4959
4960
|
if (this.retriever && input && historyEntryId) {
|
|
4960
4961
|
const retrieverNodeId = createNodeId("retriever" /* RETRIEVER */, this.retriever.tool.name, this.id);
|
|
4961
4962
|
const eventEmitter = AgentEventEmitter.getInstance();
|
|
@@ -4975,7 +4976,7 @@ Use markdown to format your answers.`;
|
|
|
4975
4976
|
try {
|
|
4976
4977
|
const context = yield this.retriever.retrieve(input);
|
|
4977
4978
|
if (context == null ? void 0 : context.trim()) {
|
|
4978
|
-
|
|
4979
|
+
finalInstructions = `${finalInstructions}
|
|
4979
4980
|
|
|
4980
4981
|
Relevant Context:
|
|
4981
4982
|
${context}`;
|
|
@@ -5000,15 +5001,18 @@ ${context}`;
|
|
|
5000
5001
|
}
|
|
5001
5002
|
if (this.subAgentManager.hasSubAgents()) {
|
|
5002
5003
|
const agentsMemory = yield this.prepareAgentsMemory(contextMessages);
|
|
5003
|
-
|
|
5004
|
+
finalInstructions = this.subAgentManager.generateSupervisorSystemMessage(
|
|
5005
|
+
finalInstructions,
|
|
5006
|
+
agentsMemory
|
|
5007
|
+
);
|
|
5004
5008
|
return {
|
|
5005
5009
|
role: "system",
|
|
5006
|
-
content:
|
|
5010
|
+
content: finalInstructions
|
|
5007
5011
|
};
|
|
5008
5012
|
}
|
|
5009
5013
|
return {
|
|
5010
5014
|
role: "system",
|
|
5011
|
-
content: `You are ${this.name}. ${
|
|
5015
|
+
content: `You are ${this.name}. ${finalInstructions}`
|
|
5012
5016
|
};
|
|
5013
5017
|
});
|
|
5014
5018
|
}
|
|
@@ -5165,6 +5169,7 @@ ${context}`;
|
|
|
5165
5169
|
id: this.id,
|
|
5166
5170
|
name: this.name,
|
|
5167
5171
|
description: this.description,
|
|
5172
|
+
instructions: this.instructions,
|
|
5168
5173
|
status: "idle",
|
|
5169
5174
|
model: this.getModelName(),
|
|
5170
5175
|
// Create a node representing this agent
|