agentnet 0.1.16 → 0.1.18

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.
@@ -5,6 +5,8 @@ metadata:
5
5
  name: entrypoint
6
6
  namespace: smartexample
7
7
  spec:
8
+ runner:
9
+ maxConversationLength: 100
8
10
  io:
9
11
  - type: NatsIO
10
12
  bindings:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentnet",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "description": "Agent library used by Smartness",
6
6
  "main": "src/index.js",
@@ -287,6 +287,10 @@ function configureRunner(agentBuilder, runnerSpec) {
287
287
  agentBuilder._config.runner.maxRuns = runnerSpec.maxRuns;
288
288
  }
289
289
 
290
+ if (runnerSpec.maxConversationLength !== undefined) {
291
+ agentBuilder._config.runner.maxConversationLength = runnerSpec.maxConversationLength;
292
+ }
293
+
290
294
  return agentBuilder;
291
295
  }
292
296
 
@@ -27,7 +27,8 @@ const DEFAULT_CONFIG = {
27
27
  apiVersion: "agentnet/v1alpha1" // Default API version
28
28
  },
29
29
  runner: {
30
- maxRuns: 10
30
+ maxRuns: 10,
31
+ maxConversationLength: 10
31
32
  }
32
33
  }
33
34
 
@@ -75,7 +76,8 @@ const AGENT_CONFIG_SCHEMA = {
75
76
  runner: {
76
77
  type: 'object',
77
78
  properties: {
78
- maxRuns: { type: 'number' }
79
+ maxRuns: { type: 'number' },
80
+ maxConversationLength: { type: 'number' }
79
81
  }
80
82
  },
81
83
  on: { type: 'object' }
@@ -214,6 +216,13 @@ export function Agent() {
214
216
  });
215
217
  }
216
218
 
219
+ validateType(config.runner.maxConversationLength, 'number', 'runner.maxConversationLength', 'agent_config');
220
+ if (config.runner.maxConversationLength <= 0) {
221
+ throw new ConfigurationError("runner.maxConversationLength must be greater than 0", {
222
+ maxConversationLength: config.runner.maxConversationLength
223
+ });
224
+ }
225
+
217
226
  logger.debug(`Agent ${config.metadata.name} configuration validated successfully`);
218
227
 
219
228
  } catch (error) {
@@ -38,7 +38,6 @@ export function makeToolsAndHandoffsMap(llmType, toolsAndHandoffsMap, tools, han
38
38
  if (!tools) {
39
39
  return;
40
40
  }
41
-
42
41
  try {
43
42
  // Process tools
44
43
  for (const tool of tools) {
@@ -46,6 +45,10 @@ export function makeToolsAndHandoffsMap(llmType, toolsAndHandoffsMap, tools, han
46
45
  logger.warn('Skipping undefined tool');
47
46
  continue;
48
47
  }
48
+ if (toolsAndHandoffsMap[tool.name] !== undefined) {
49
+ logger.warn('Skipping duplicate tool', { tool });
50
+ continue;
51
+ }
49
52
 
50
53
  if (!tool.schema) {
51
54
  toolsAndHandoffsMap.tools.push(tool);
@@ -76,6 +79,11 @@ export function makeToolsAndHandoffsMap(llmType, toolsAndHandoffsMap, tools, han
76
79
  if (llmType === 'openai') {
77
80
  handoff.schema.type = 'function'
78
81
  }
82
+
83
+ if (toolsAndHandoffsMap[handoff.name] !== undefined) {
84
+ logger.warn('Skipping duplicate handoff', { handoff });
85
+ continue;
86
+ }
79
87
 
80
88
  // Add handoff schema to tools list
81
89
  toolsAndHandoffsMap.tools.push(handoff.schema);
@@ -108,7 +108,7 @@ export async function AgentRuntime(agentConfig) {
108
108
  await store.instance.connect()
109
109
  sessionStore.setConversation(storeState.conversation)
110
110
  sessionStore.setState(storeState.state)
111
- sessionStore.trimConversation(10)
111
+ sessionStore.trimConversation(runner?.maxConversationLength || 10)
112
112
  await sessionStore.dump(store.instance)
113
113
  logger.info(`Dumped session state for agent ${agentName} with session id ${storeStateSessionId}, current conversation length ${storeState.conversation.getRawConversation().length}`);
114
114
  }
package/src/llm/gemini.js CHANGED
@@ -42,7 +42,6 @@ class GeminiLLM extends BaseLLM {
42
42
  */
43
43
  async callModel(llmClientConfig, context) {
44
44
  const { client, toolsAndHandoffsMap, conversation } = context;
45
-
46
45
  // conversation is always a Conversation object
47
46
  const input = { ...llmClientConfig, contents: conversation.getRawConversation() };
48
47
 
@@ -61,6 +60,7 @@ class GeminiLLM extends BaseLLM {
61
60
  });
62
61
 
63
62
  try {
63
+
64
64
  const res = await client.models.generateContent(input);
65
65
  logger.debug('Gemini response', res)
66
66
  logger.debug('Gemini response received', {