@opperai/agents 0.2.0 → 0.3.0-beta

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.js CHANGED
@@ -943,6 +943,28 @@ var BaseAgent = class {
943
943
  * Opper client configuration
944
944
  */
945
945
  opperConfig;
946
+ /**
947
+ * Creates a new BaseAgent instance
948
+ *
949
+ * @param config - Agent configuration object
950
+ * @param config.name - Unique name identifying this agent (required)
951
+ * @param config.description - Human-readable description of the agent's purpose
952
+ * @param config.instructions - System instructions guiding agent behavior
953
+ * @param config.tools - Array of tools or tool providers available to the agent
954
+ * @param config.maxIterations - Maximum iterations before terminating the agent loop (default: 25)
955
+ * @param config.model - Model identifier(s). Single model or array for fallback (default: "gcp/gemini-flash-latest")
956
+ * @param config.inputSchema - Zod schema for input validation
957
+ * @param config.outputSchema - Zod schema for output validation
958
+ * @param config.enableStreaming - Enable Opper streaming APIs for LLM calls (default: false)
959
+ * @param config.enableMemory - Enable memory subsystem (default: false)
960
+ * @param config.memory - Custom memory implementation (defaults to InMemoryStore if enableMemory is true)
961
+ * @param config.metadata - Additional metadata for the agent
962
+ * @param config.opperConfig - Opper API configuration containing apiKey and baseUrl
963
+ * @param config.onStreamStart - Handler invoked when a streaming call starts
964
+ * @param config.onStreamChunk - Handler invoked for each streaming chunk
965
+ * @param config.onStreamEnd - Handler invoked when a streaming call ends
966
+ * @param config.onStreamError - Handler invoked when streaming encounters an error
967
+ */
946
968
  constructor(config) {
947
969
  this.name = config.name;
948
970
  this.description = config.description;
@@ -1443,6 +1465,10 @@ var AgentDecisionSchema = z.object({
1443
1465
  * Agent's internal reasoning
1444
1466
  */
1445
1467
  reasoning: z.string(),
1468
+ /**
1469
+ * Status message for the user (e.g., "Searching for information...", "Processing results...")
1470
+ */
1471
+ userMessage: z.string().default("Working on it..."),
1446
1472
  /**
1447
1473
  * Tool calls to execute (if any)
1448
1474
  * Empty array signals task completion
@@ -1455,8 +1481,34 @@ var AgentDecisionSchema = z.object({
1455
1481
  /**
1456
1482
  * Memory entries to write/update (key -> payload)
1457
1483
  */
1458
- memoryUpdates: z.record(MemoryUpdateSchema).default({})
1484
+ memoryUpdates: z.record(MemoryUpdateSchema).default({}),
1485
+ /**
1486
+ * Whether the task is complete and finalResult is available
1487
+ * (single LLM call pattern)
1488
+ */
1489
+ isComplete: z.boolean().default(false),
1490
+ /**
1491
+ * The final result when isComplete=true
1492
+ * Should match outputSchema if specified
1493
+ */
1494
+ finalResult: z.unknown().optional()
1459
1495
  });
1496
+ function createAgentDecisionWithOutputSchema(outputSchema) {
1497
+ if (!outputSchema) {
1498
+ return AgentDecisionSchema;
1499
+ }
1500
+ const finalResultSchema = outputSchema.optional();
1501
+ const dynamicSchema = z.object({
1502
+ reasoning: z.string(),
1503
+ userMessage: z.string().default("Working on it..."),
1504
+ toolCalls: z.array(ToolCallSchema).default([]),
1505
+ memoryReads: z.array(z.string()).default([]),
1506
+ memoryUpdates: z.record(MemoryUpdateSchema).default({}),
1507
+ isComplete: z.boolean().default(false),
1508
+ finalResult: finalResultSchema
1509
+ });
1510
+ return dynamicSchema;
1511
+ }
1460
1512
  var ToolExecutionSummarySchema = z.object({
1461
1513
  /**
1462
1514
  * Tool name
@@ -1478,7 +1530,7 @@ var ToolExecutionSummarySchema = z.object({
1478
1530
 
1479
1531
  // package.json
1480
1532
  var package_default = {
1481
- version: "0.2.0"};
1533
+ version: "0.3.0-beta"};
1482
1534
 
1483
1535
  // src/utils/version.ts
1484
1536
  var SDK_NAME = "@opperai/agents";
@@ -1606,7 +1658,8 @@ var OpperClient = class {
1606
1658
  const span = await this.client.spans.create({
1607
1659
  name: options.name,
1608
1660
  ...options.input !== void 0 && { input: options.input },
1609
- ...options.parentSpanId && { parentId: options.parentSpanId }
1661
+ ...options.parentSpanId && { parentId: options.parentSpanId },
1662
+ ...options.type && { type: options.type }
1610
1663
  });
1611
1664
  return {
1612
1665
  id: span.id,
@@ -1623,7 +1676,11 @@ var OpperClient = class {
1623
1676
  const serializedOutput = output !== void 0 && output !== null ? typeof output === "object" ? JSON.stringify(output) : String(output) : void 0;
1624
1677
  await this.client.spans.update(spanId, {
1625
1678
  ...serializedOutput !== void 0 && { output: serializedOutput },
1626
- ...options?.error && { error: options.error }
1679
+ ...options?.error && { error: options.error },
1680
+ ...options?.startTime && { startTime: options.startTime },
1681
+ ...options?.endTime && { endTime: options.endTime },
1682
+ ...options?.meta && { meta: options.meta },
1683
+ ...options?.name && { name: options.name }
1627
1684
  });
1628
1685
  }, `update-span:${spanId}`);
1629
1686
  }
@@ -1941,7 +1998,11 @@ var StreamAssembler = class {
1941
1998
  if (path === STREAM_ROOT_PATH) {
1942
1999
  continue;
1943
2000
  }
1944
- const value = resolveFieldValue(path, this.displayBuffers, this.valueBuffers);
2001
+ const value = resolveFieldValue(
2002
+ path,
2003
+ this.displayBuffers,
2004
+ this.valueBuffers
2005
+ );
1945
2006
  setNestedValue(result, path, value);
1946
2007
  }
1947
2008
  return normalizeIndexed(result);
@@ -1961,6 +2022,31 @@ var Agent = class extends BaseAgent {
1961
2022
  opperClient;
1962
2023
  logger;
1963
2024
  verbose;
2025
+ /**
2026
+ * Creates a new Agent instance
2027
+ *
2028
+ * @param config - Agent configuration object
2029
+ * @param config.name - Unique name identifying this agent (required)
2030
+ * @param config.description - Human-readable description of the agent's purpose
2031
+ * @param config.instructions - System instructions guiding agent behavior
2032
+ * @param config.tools - Array of tools or tool providers available to the agent
2033
+ * @param config.maxIterations - Maximum iterations before terminating (default: 25)
2034
+ * @param config.model - Model identifier(s) as string or array for fallback (default: "gcp/gemini-flash-latest")
2035
+ * @param config.inputSchema - Zod schema for input validation
2036
+ * @param config.outputSchema - Zod schema for output validation
2037
+ * @param config.enableStreaming - Enable streaming for LLM calls (default: false)
2038
+ * @param config.enableMemory - Enable memory subsystem (default: false)
2039
+ * @param config.memory - Custom memory implementation (defaults to InMemoryStore if enableMemory is true)
2040
+ * @param config.metadata - Additional metadata for the agent
2041
+ * @param config.opperConfig - Opper API configuration (apiKey, baseUrl)
2042
+ * @param config.opperClient - Custom Opper client instance (for testing or custom configuration)
2043
+ * @param config.logger - Logger instance for debugging
2044
+ * @param config.verbose - Enable verbose logging (default: false)
2045
+ * @param config.onStreamStart - Handler invoked when streaming starts
2046
+ * @param config.onStreamChunk - Handler invoked for each streaming chunk
2047
+ * @param config.onStreamEnd - Handler invoked when streaming ends
2048
+ * @param config.onStreamError - Handler invoked on streaming errors
2049
+ */
1964
2050
  constructor(config) {
1965
2051
  super(config);
1966
2052
  this.logger = config.logger ?? getDefaultLogger();
@@ -1996,6 +2082,7 @@ var Agent = class extends BaseAgent {
1996
2082
  maxIterations: this.maxIterations,
1997
2083
  tools: Array.from(this.tools.keys())
1998
2084
  });
2085
+ const executionStartTime = /* @__PURE__ */ new Date();
1999
2086
  const parentSpan = await this.opperClient.createSpan({
2000
2087
  name: `${this.name}_execution`,
2001
2088
  input: this.serializeInput(input),
@@ -2015,6 +2102,47 @@ var Agent = class extends BaseAgent {
2015
2102
  input,
2016
2103
  context
2017
2104
  );
2105
+ if (decision.isComplete && decision.finalResult !== void 0) {
2106
+ this.log("Task completed with final result in single call", {
2107
+ iteration: currentIteration
2108
+ });
2109
+ let finalResult;
2110
+ if (this.outputSchema) {
2111
+ const parseResult = this.outputSchema.safeParse(
2112
+ decision.finalResult
2113
+ );
2114
+ if (parseResult.success) {
2115
+ finalResult = parseResult.data;
2116
+ } else {
2117
+ this.logger.warn(
2118
+ "Final result validation against output schema failed, falling back to generate_final_result",
2119
+ { error: parseResult.error.message }
2120
+ );
2121
+ break;
2122
+ }
2123
+ } else {
2124
+ const rawResult = decision.finalResult;
2125
+ if (typeof rawResult === "string") {
2126
+ finalResult = rawResult;
2127
+ } else if (rawResult === null || rawResult === void 0) {
2128
+ finalResult = "";
2129
+ } else if (typeof rawResult === "object") {
2130
+ finalResult = JSON.stringify(rawResult);
2131
+ } else {
2132
+ finalResult = String(rawResult);
2133
+ }
2134
+ }
2135
+ const executionEndTime2 = /* @__PURE__ */ new Date();
2136
+ await this.opperClient.updateSpan(parentSpan.id, finalResult, {
2137
+ startTime: executionStartTime,
2138
+ endTime: executionEndTime2,
2139
+ meta: {
2140
+ durationMs: executionEndTime2.getTime() - executionStartTime.getTime()
2141
+ }
2142
+ });
2143
+ await this.triggerHook(HookEvents.LoopEnd, { context });
2144
+ return finalResult;
2145
+ }
2018
2146
  const memoryResults = await this.handleMemoryActions(
2019
2147
  decision,
2020
2148
  context,
@@ -2024,7 +2152,7 @@ var Agent = class extends BaseAgent {
2024
2152
  const toolResults = await this.executeToolCalls(
2025
2153
  decision,
2026
2154
  context,
2027
- thinkSpanId
2155
+ context.parentSpanId ?? void 0
2028
2156
  );
2029
2157
  const combinedResults = [...memoryResults, ...toolResults];
2030
2158
  const newToolCalls = context.toolCalls.slice(toolCallStartIndex);
@@ -2059,11 +2187,24 @@ var Agent = class extends BaseAgent {
2059
2187
  );
2060
2188
  }
2061
2189
  const result = await this.generateFinalResult(input, context);
2062
- await this.opperClient.updateSpan(parentSpan.id, result);
2190
+ const executionEndTime = /* @__PURE__ */ new Date();
2191
+ await this.opperClient.updateSpan(parentSpan.id, result, {
2192
+ startTime: executionStartTime,
2193
+ endTime: executionEndTime,
2194
+ meta: {
2195
+ durationMs: executionEndTime.getTime() - executionStartTime.getTime()
2196
+ }
2197
+ });
2063
2198
  return result;
2064
2199
  } catch (error) {
2200
+ const executionEndTime = /* @__PURE__ */ new Date();
2065
2201
  await this.opperClient.updateSpan(parentSpan.id, void 0, {
2066
- error: error instanceof Error ? error.message : String(error)
2202
+ error: error instanceof Error ? error.message : String(error),
2203
+ startTime: executionStartTime,
2204
+ endTime: executionEndTime,
2205
+ meta: {
2206
+ durationMs: executionEndTime.getTime() - executionStartTime.getTime()
2207
+ }
2067
2208
  });
2068
2209
  throw error;
2069
2210
  }
@@ -2072,11 +2213,15 @@ var Agent = class extends BaseAgent {
2072
2213
  * Think step: Call LLM to decide next action
2073
2214
  */
2074
2215
  async think(input, context) {
2075
- const spanName = "think";
2216
+ const sanitizedName = this.name.toLowerCase().replace(/[\s-]/g, "_");
2217
+ const spanName = `think_${sanitizedName}`;
2076
2218
  this.log("Think step", { iteration: context.iteration });
2077
2219
  await this.triggerHook(HookEvents.LlmCall, { context, callType: "think" });
2220
+ const decisionSchema = createAgentDecisionWithOutputSchema(
2221
+ this.outputSchema
2222
+ );
2078
2223
  if (this.enableStreaming) {
2079
- return this.thinkStreaming(input, context);
2224
+ return this.thinkStreaming(input, context, decisionSchema, spanName);
2080
2225
  }
2081
2226
  try {
2082
2227
  const instructions = this.buildThinkInstructions();
@@ -2085,7 +2230,7 @@ var Agent = class extends BaseAgent {
2085
2230
  name: spanName,
2086
2231
  instructions,
2087
2232
  input: thinkContext,
2088
- outputSchema: AgentDecisionSchema,
2233
+ outputSchema: decisionSchema,
2089
2234
  model: this.model,
2090
2235
  ...context.parentSpanId && { parentSpanId: context.parentSpanId }
2091
2236
  });
@@ -2096,15 +2241,25 @@ var Agent = class extends BaseAgent {
2096
2241
  totalTokens: response.usage.totalTokens,
2097
2242
  cost: response.usage.cost
2098
2243
  });
2099
- const decision = AgentDecisionSchema.parse(response.jsonPayload);
2244
+ const decision = decisionSchema.parse(
2245
+ response.jsonPayload
2246
+ );
2100
2247
  await this.triggerHook(HookEvents.LlmResponse, {
2101
2248
  context,
2102
2249
  callType: "think",
2103
2250
  response
2104
2251
  });
2252
+ if (response.spanId) {
2253
+ await this.opperClient.updateSpan(response.spanId, void 0, {
2254
+ name: "think"
2255
+ });
2256
+ }
2105
2257
  await this.triggerHook(HookEvents.ThinkEnd, {
2106
2258
  context,
2107
- thought: { reasoning: decision.reasoning }
2259
+ thought: {
2260
+ reasoning: decision.reasoning,
2261
+ userMessage: decision.userMessage
2262
+ }
2108
2263
  });
2109
2264
  this.log("Think result", {
2110
2265
  reasoning: decision.reasoning,
@@ -2120,12 +2275,11 @@ var Agent = class extends BaseAgent {
2120
2275
  );
2121
2276
  }
2122
2277
  }
2123
- async thinkStreaming(input, context) {
2124
- const spanName = "think";
2278
+ async thinkStreaming(input, context, decisionSchema, spanName) {
2125
2279
  const instructions = this.buildThinkInstructions();
2126
2280
  const thinkContext = await this.buildThinkContext(input, context);
2127
2281
  const assembler = createStreamAssembler({
2128
- schema: AgentDecisionSchema
2282
+ schema: decisionSchema
2129
2283
  });
2130
2284
  let streamSpanId;
2131
2285
  await this.triggerHook(HookEvents.StreamStart, {
@@ -2141,7 +2295,7 @@ var Agent = class extends BaseAgent {
2141
2295
  name: spanName,
2142
2296
  instructions,
2143
2297
  input: thinkContext,
2144
- outputSchema: AgentDecisionSchema,
2298
+ outputSchema: decisionSchema,
2145
2299
  model: this.model,
2146
2300
  ...context.parentSpanId && { parentSpanId: context.parentSpanId }
2147
2301
  });
@@ -2185,11 +2339,11 @@ var Agent = class extends BaseAgent {
2185
2339
  const finalize = assembler.finalize();
2186
2340
  let decision;
2187
2341
  if (finalize.type === "structured" && finalize.structured) {
2188
- decision = AgentDecisionSchema.parse(
2342
+ decision = decisionSchema.parse(
2189
2343
  finalize.structured
2190
2344
  );
2191
2345
  } else {
2192
- decision = AgentDecisionSchema.parse({
2346
+ decision = decisionSchema.parse({
2193
2347
  reasoning: finalize.type === "root" ? finalize.rootText ?? "" : ""
2194
2348
  });
2195
2349
  }
@@ -2212,9 +2366,17 @@ var Agent = class extends BaseAgent {
2212
2366
  response: streamResponse,
2213
2367
  parsed: decision
2214
2368
  });
2369
+ if (streamSpanId) {
2370
+ await this.opperClient.updateSpan(streamSpanId, void 0, {
2371
+ name: "think"
2372
+ });
2373
+ }
2215
2374
  await this.triggerHook(HookEvents.ThinkEnd, {
2216
2375
  context,
2217
- thought: { reasoning: decision.reasoning }
2376
+ thought: {
2377
+ reasoning: decision.reasoning,
2378
+ userMessage: decision.userMessage
2379
+ }
2218
2380
  });
2219
2381
  this.log("Think result", {
2220
2382
  reasoning: decision.reasoning,
@@ -2256,12 +2418,22 @@ YOUR TASK:
2256
2418
  1. Analyze the current situation
2257
2419
  2. Decide if the goal is complete or more actions are needed
2258
2420
  3. If more actions needed: specify tools to call
2259
- 4. If goal complete: return empty tool_calls list
2421
+ 4. If goal complete:
2422
+ - Set isComplete=true
2423
+ - Provide the complete answer/output in finalResult
2424
+ - Leave toolCalls empty
2260
2425
 
2261
2426
  IMPORTANT:
2262
- - Return empty toolCalls array when task is COMPLETE
2427
+ - When task is COMPLETE, you MUST set isComplete=true AND provide finalResult
2428
+ - The finalResult should be a complete, well-structured answer based on all work done
2263
2429
  - Only use available tools
2264
- - Provide clear reasoning for each decision`;
2430
+ - Provide clear reasoning for each decision
2431
+ - If an outputSchema was specified, ensure finalResult matches that schema
2432
+
2433
+ USER MESSAGE:
2434
+ - Always provide a brief, user-friendly status in userMessage
2435
+ - This message is shown to users to indicate progress (e.g., "Searching for weather data...", "Calculating results...", "Done!")
2436
+ - Keep it concise and informative`;
2265
2437
  if (this.enableMemory) {
2266
2438
  instructions += `
2267
2439
 
@@ -2345,9 +2517,14 @@ The memory you write persists across all process() calls on this agent.`;
2345
2517
  this.log(`Action: ${toolCall.toolName}`, {
2346
2518
  parameters: toolCall.arguments
2347
2519
  });
2520
+ const startTime = /* @__PURE__ */ new Date();
2521
+ const tool2 = this.tools.get(toolCall.toolName);
2522
+ const isAgentTool = tool2?.metadata?.["isAgent"] === true;
2523
+ const spanType = isAgentTool ? "\u{1F916} agent" : "\u{1F527} tool";
2348
2524
  const toolSpan = await this.opperClient.createSpan({
2349
2525
  name: `tool_${toolCall.toolName}`,
2350
2526
  input: toolCall.arguments,
2527
+ type: spanType,
2351
2528
  ...parentSpanId ? { parentSpanId } : context.parentSpanId ? { parentSpanId: context.parentSpanId } : {}
2352
2529
  });
2353
2530
  try {
@@ -2357,11 +2534,20 @@ The memory you write persists across all process() calls on this agent.`;
2357
2534
  context,
2358
2535
  { spanId: toolSpan.id }
2359
2536
  );
2537
+ const endTime = /* @__PURE__ */ new Date();
2538
+ const durationMs = endTime.getTime() - startTime.getTime();
2360
2539
  if (result.success) {
2361
- await this.opperClient.updateSpan(toolSpan.id, result.output);
2540
+ await this.opperClient.updateSpan(toolSpan.id, result.output, {
2541
+ startTime,
2542
+ endTime,
2543
+ meta: { durationMs }
2544
+ });
2362
2545
  } else {
2363
2546
  await this.opperClient.updateSpan(toolSpan.id, void 0, {
2364
- error: result.error instanceof Error ? result.error.message : String(result.error)
2547
+ error: result.error instanceof Error ? result.error.message : String(result.error),
2548
+ startTime,
2549
+ endTime,
2550
+ meta: { durationMs }
2365
2551
  });
2366
2552
  }
2367
2553
  const summary = {
@@ -2376,12 +2562,18 @@ The memory you write persists across all process() calls on this agent.`;
2376
2562
  this.log(
2377
2563
  `Tool ${toolCall.toolName} ${result.success ? "succeeded" : "failed"}`,
2378
2564
  {
2379
- success: result.success
2565
+ success: result.success,
2566
+ durationMs
2380
2567
  }
2381
2568
  );
2382
2569
  } catch (error) {
2570
+ const endTime = /* @__PURE__ */ new Date();
2571
+ const durationMs = endTime.getTime() - startTime.getTime();
2383
2572
  await this.opperClient.updateSpan(toolSpan.id, void 0, {
2384
- error: error instanceof Error ? error.message : String(error)
2573
+ error: error instanceof Error ? error.message : String(error),
2574
+ startTime,
2575
+ endTime,
2576
+ meta: { durationMs }
2385
2577
  });
2386
2578
  const summary = {
2387
2579
  toolName: toolCall.toolName,
@@ -2390,7 +2582,8 @@ The memory you write persists across all process() calls on this agent.`;
2390
2582
  };
2391
2583
  results.push(ToolExecutionSummarySchema.parse(summary));
2392
2584
  this.logger.warn(`Tool ${toolCall.toolName} threw error`, {
2393
- error: error instanceof Error ? error.message : String(error)
2585
+ error: error instanceof Error ? error.message : String(error),
2586
+ durationMs
2394
2587
  });
2395
2588
  }
2396
2589
  }
@@ -2419,6 +2612,7 @@ The memory you write persists across all process() calls on this agent.`;
2419
2612
  const spanParentId = parentSpanId ?? context.parentSpanId ?? void 0;
2420
2613
  const summaries = [];
2421
2614
  if (hasReads) {
2615
+ const startTime = /* @__PURE__ */ new Date();
2422
2616
  try {
2423
2617
  const keySet = new Set(
2424
2618
  decision.memoryReads.filter(
@@ -2430,10 +2624,17 @@ The memory you write persists across all process() calls on this agent.`;
2430
2624
  const memoryReadSpan = await this.opperClient.createSpan({
2431
2625
  name: "memory_read",
2432
2626
  input: keys,
2627
+ type: "\u{1F9E0} memory",
2433
2628
  ...spanParentId && { parentSpanId: spanParentId }
2434
2629
  });
2435
2630
  const memoryData = await this.memory.read(keys);
2436
- await this.opperClient.updateSpan(memoryReadSpan.id, memoryData);
2631
+ const endTime = /* @__PURE__ */ new Date();
2632
+ const durationMs = endTime.getTime() - startTime.getTime();
2633
+ await this.opperClient.updateSpan(memoryReadSpan.id, memoryData, {
2634
+ startTime,
2635
+ endTime,
2636
+ meta: { durationMs }
2637
+ });
2437
2638
  context.setMetadata("current_memory", memoryData);
2438
2639
  this.log(`Loaded ${Object.keys(memoryData).length} memory entries`, {
2439
2640
  keys
@@ -2472,10 +2673,12 @@ The memory you write persists across all process() calls on this agent.`;
2472
2673
  }
2473
2674
  }
2474
2675
  if (hasWrites) {
2676
+ const startTime = /* @__PURE__ */ new Date();
2475
2677
  try {
2476
2678
  const memoryWriteSpan = await this.opperClient.createSpan({
2477
2679
  name: "memory_write",
2478
2680
  input: updateEntries.map(([key]) => key),
2681
+ type: "\u{1F9E0} memory",
2479
2682
  ...spanParentId && { parentSpanId: spanParentId }
2480
2683
  });
2481
2684
  for (const [key, update] of updateEntries) {
@@ -2492,9 +2695,16 @@ The memory you write persists across all process() calls on this agent.`;
2492
2695
  value: castUpdate.value
2493
2696
  });
2494
2697
  }
2698
+ const endTime = /* @__PURE__ */ new Date();
2699
+ const durationMs = endTime.getTime() - startTime.getTime();
2495
2700
  await this.opperClient.updateSpan(
2496
2701
  memoryWriteSpan.id,
2497
- `Successfully wrote ${updateEntries.length} keys`
2702
+ `Successfully wrote ${updateEntries.length} keys`,
2703
+ {
2704
+ startTime,
2705
+ endTime,
2706
+ meta: { durationMs }
2707
+ }
2498
2708
  );
2499
2709
  this.log(`Wrote ${updateEntries.length} memory entries`);
2500
2710
  summaries.push(
@@ -2567,8 +2777,10 @@ Follow any instructions provided for formatting and style.`;
2567
2777
  );
2568
2778
  }
2569
2779
  try {
2780
+ const sanitizedName = this.name.toLowerCase().replace(/[\s-]/g, "_");
2781
+ const functionName = `generate_final_result_${sanitizedName}`;
2570
2782
  const callOptions = {
2571
- name: "generate_final_result",
2783
+ name: functionName,
2572
2784
  instructions,
2573
2785
  input: finalContext,
2574
2786
  model: this.model
@@ -2615,8 +2827,10 @@ Follow any instructions provided for formatting and style.`;
2615
2827
  callType: "final_result"
2616
2828
  });
2617
2829
  try {
2830
+ const sanitizedName = this.name.toLowerCase().replace(/[\s-]/g, "_");
2831
+ const functionName = `generate_final_result_${sanitizedName}`;
2618
2832
  const streamResponse = await this.opperClient.stream({
2619
- name: "generate_final_result",
2833
+ name: functionName,
2620
2834
  instructions,
2621
2835
  input: finalContext,
2622
2836
  model: this.model,
@@ -3530,6 +3744,6 @@ var ToolRunner = class {
3530
3744
  }
3531
3745
  };
3532
3746
 
3533
- export { Agent, AgentContext, AgentDecisionSchema, AgentEventEmitter, AgentEvents, BaseAgent, ConsoleLogger, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, ExecutionCycleSchema, HookEvents, HookManager, InMemoryStore, LogLevel, MCPClient, MCPServerConfigSchema, MCPToolProvider, MCPconfig, MemoryEntryMetadataSchema, MemoryEntrySchema, MemoryUpdateSchema, OpperClient, Result, STREAM_ROOT_PATH, SchemaValidationError, SilentLogger, StreamAssembler, ThoughtSchema, ToolCallRecordSchema, ToolCallSchema, ToolExecutionSummarySchema, ToolMetadataSchema, ToolResultFactory, ToolResultFailureSchema, ToolResultSchema, ToolResultSuccessSchema, ToolRunner, UsageSchema, coerceToolDefinition, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput };
3747
+ export { Agent, AgentContext, AgentDecisionSchema, AgentEventEmitter, AgentEvents, BaseAgent, ConsoleLogger, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, ExecutionCycleSchema, HookEvents, HookManager, InMemoryStore, LogLevel, MCPClient, MCPServerConfigSchema, MCPToolProvider, MCPconfig, MemoryEntryMetadataSchema, MemoryEntrySchema, MemoryUpdateSchema, OpperClient, Result, STREAM_ROOT_PATH, SchemaValidationError, SilentLogger, StreamAssembler, ThoughtSchema, ToolCallRecordSchema, ToolCallSchema, ToolExecutionSummarySchema, ToolMetadataSchema, ToolResultFactory, ToolResultFailureSchema, ToolResultSchema, ToolResultSuccessSchema, ToolRunner, UsageSchema, coerceToolDefinition, createAgentDecisionWithOutputSchema, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput };
3534
3748
  //# sourceMappingURL=index.js.map
3535
3749
  //# sourceMappingURL=index.js.map