@voltagent/core 0.1.12 → 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 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
- description: "A helpful assistant that answers questions without using tools",
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(baseDescription: string, agentsMemory?: string): string;
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
- * Agent description
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: Omit<AgentOptions, "provider" | "model"> & TProvider & {
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(baseDescription, agentsMemory = "") {
4321
+ generateSupervisorSystemMessage(baseInstructions, agentsMemory = "") {
4322
4322
  if (this.subAgents.length === 0) {
4323
- return baseDescription;
4323
+ return baseInstructions;
4324
4324
  }
4325
- const subAgentList = this.subAgents.map((agent) => `- ${agent.name}: ${agent.description}`).join("\n");
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
- ${baseDescription}
4334
+ ${baseInstructions}
4335
4335
  </instructions>
4336
4336
 
4337
4337
  <guidelines>
@@ -4630,9 +4630,6 @@ __name(startOperationSpan, "startOperationSpan");
4630
4630
  function endOperationSpan(options) {
4631
4631
  const { span, status, data } = options;
4632
4632
  if (!span || !span.isRecording()) {
4633
- console.warn(
4634
- "[VoltAgentCore OTEL] Attempted to end a non-recording or undefined operation span."
4635
- );
4636
4633
  return;
4637
4634
  }
4638
4635
  try {
@@ -4710,7 +4707,6 @@ function endToolSpan(options) {
4710
4707
  var _a, _b, _c;
4711
4708
  const { span, resultData } = options;
4712
4709
  if (!span || !span.isRecording()) {
4713
- console.warn("[VoltAgentCore OTEL] Attempted to end a non-recording or undefined tool span.");
4714
4710
  return;
4715
4711
  }
4716
4712
  try {
@@ -4847,7 +4843,8 @@ var Agent = class {
4847
4843
  toolId: toolCallId
4848
4844
  }, standardData), userContextData && { userContext: userContextData });
4849
4845
  internalEventData.metadata = __spreadProps(__spreadValues({}, internalEventData.metadata), {
4850
- sourceAgentId: this.id
4846
+ sourceAgentId: this.id,
4847
+ toolName
4851
4848
  });
4852
4849
  const eventEmitter = AgentEventEmitter.getInstance();
4853
4850
  const eventUpdater = yield eventEmitter.createTrackedEvent({
@@ -4908,15 +4905,16 @@ var Agent = class {
4908
4905
  context
4909
4906
  );
4910
4907
  }, "addAgentEvent");
4911
- var _a;
4908
+ var _a, _b, _c;
4912
4909
  this.id = options.id || options.name;
4913
4910
  this.name = options.name;
4914
- this.description = options.description || "A helpful AI assistant";
4911
+ this.instructions = (_b = (_a = options.instructions) != null ? _a : options.description) != null ? _b : "A helpful AI assistant";
4912
+ this.description = this.instructions;
4915
4913
  this.llm = options.llm;
4916
4914
  this.model = options.model;
4917
4915
  this.retriever = options.retriever;
4918
4916
  this.voice = options.voice;
4919
- this.markdown = (_a = options.markdown) != null ? _a : false;
4917
+ this.markdown = (_c = options.markdown) != null ? _c : false;
4920
4918
  if (options.hooks) {
4921
4919
  this.hooks = options.hooks;
4922
4920
  } else {
@@ -4940,7 +4938,7 @@ var Agent = class {
4940
4938
  historyEntryId,
4941
4939
  contextMessages
4942
4940
  }) {
4943
- let baseDescription = this.description || "";
4941
+ let baseInstructions = this.instructions || "";
4944
4942
  let toolInstructions = "";
4945
4943
  const toolkits = this.toolManager.getToolkits();
4946
4944
  for (const toolkit of toolkits) {
@@ -4951,14 +4949,14 @@ ${toolkit.instructions}`;
4951
4949
  }
4952
4950
  }
4953
4951
  if (toolInstructions) {
4954
- baseDescription = `${baseDescription}${toolInstructions}`;
4952
+ baseInstructions = `${baseInstructions}${toolInstructions}`;
4955
4953
  }
4956
4954
  if (this.markdown) {
4957
- baseDescription = `${baseDescription}
4955
+ baseInstructions = `${baseInstructions}
4958
4956
 
4959
4957
  Use markdown to format your answers.`;
4960
4958
  }
4961
- let description = baseDescription;
4959
+ let finalInstructions = baseInstructions;
4962
4960
  if (this.retriever && input && historyEntryId) {
4963
4961
  const retrieverNodeId = createNodeId("retriever" /* RETRIEVER */, this.retriever.tool.name, this.id);
4964
4962
  const eventEmitter = AgentEventEmitter.getInstance();
@@ -4978,7 +4976,7 @@ Use markdown to format your answers.`;
4978
4976
  try {
4979
4977
  const context = yield this.retriever.retrieve(input);
4980
4978
  if (context == null ? void 0 : context.trim()) {
4981
- description = `${description}
4979
+ finalInstructions = `${finalInstructions}
4982
4980
 
4983
4981
  Relevant Context:
4984
4982
  ${context}`;
@@ -5003,15 +5001,18 @@ ${context}`;
5003
5001
  }
5004
5002
  if (this.subAgentManager.hasSubAgents()) {
5005
5003
  const agentsMemory = yield this.prepareAgentsMemory(contextMessages);
5006
- description = this.subAgentManager.generateSupervisorSystemMessage(description, agentsMemory);
5004
+ finalInstructions = this.subAgentManager.generateSupervisorSystemMessage(
5005
+ finalInstructions,
5006
+ agentsMemory
5007
+ );
5007
5008
  return {
5008
5009
  role: "system",
5009
- content: description
5010
+ content: finalInstructions
5010
5011
  };
5011
5012
  }
5012
5013
  return {
5013
5014
  role: "system",
5014
- content: `You are ${this.name}. ${description}`
5015
+ content: `You are ${this.name}. ${finalInstructions}`
5015
5016
  };
5016
5017
  });
5017
5018
  }
@@ -5168,6 +5169,7 @@ ${context}`;
5168
5169
  id: this.id,
5169
5170
  name: this.name,
5170
5171
  description: this.description,
5172
+ instructions: this.instructions,
5171
5173
  status: "idle",
5172
5174
  model: this.getModelName(),
5173
5175
  // Create a node representing this agent