@looopy-ai/core 2.1.19 → 2.1.20

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.
@@ -1,7 +1,5 @@
1
1
  import { concat, defer, filter, map, mergeMap, shareReplay } from 'rxjs';
2
2
  import { startLLMCallSpan, startLoopIterationSpan } from '../observability/spans';
3
- import { toolErrorEvent } from '../tools/tool-result-events';
4
- import { safeValidateToolCall } from '../types/tools';
5
3
  import { getSystemPrompts } from '../utils/prompt';
6
4
  import { runToolCall } from './tools';
7
5
  export const runIteration = (context, config, history) => {
@@ -37,35 +35,7 @@ export const runIteration = (context, config, history) => {
37
35
  stream: true,
38
36
  sessionId: context.taskId,
39
37
  })
40
- .pipe(finishLLMCallSpan, map((event) => {
41
- if (event.kind === 'tool-call') {
42
- const validation = safeValidateToolCall({
43
- id: event.toolCallId,
44
- type: 'function',
45
- function: {
46
- name: event.toolName,
47
- arguments: event.arguments,
48
- },
49
- });
50
- if (!validation.success) {
51
- const errorMessage = `Invalid tool call format: ${(validation.errors || []).map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}`;
52
- context.logger.error({
53
- toolCallId: event.toolCallId,
54
- toolName: event.toolName,
55
- errors: validation.errors,
56
- }, 'Invalid tool call from LLM - tool name must match ^[a-zA-Z0-9_-]+$');
57
- return toolErrorEvent({
58
- id: event.toolCallId,
59
- type: 'function',
60
- function: {
61
- name: event.toolName,
62
- arguments: event.arguments,
63
- },
64
- }, errorMessage);
65
- }
66
- }
67
- return event;
68
- }), map((event) => ({
38
+ .pipe(finishLLMCallSpan, map((event) => ({
69
39
  contextId: context.contextId,
70
40
  taskId: context.taskId,
71
41
  path: undefined,
@@ -88,7 +88,7 @@ export class LiteLLMProvider {
88
88
  id: tc.id,
89
89
  type: 'function',
90
90
  function: {
91
- name: tc.function?.name,
91
+ name: fixToolFunctionName(tc.function?.name),
92
92
  arguments: (typeof tc.function?.arguments === 'string'
93
93
  ? JSON.parse(tc.function?.arguments)
94
94
  : tc.function?.arguments) || {},
@@ -111,7 +111,7 @@ export class LiteLLMProvider {
111
111
  const toolCalls$ = contentComplete$.pipe(filter((event) => event.finishReason === 'tool_calls'), mergeMap((event) => event.toolCalls?.map((tc) => ({
112
112
  kind: 'tool-call',
113
113
  toolCallId: tc.id,
114
- toolName: tc.function.name,
114
+ toolName: fixToolFunctionName(tc.function.name),
115
115
  arguments: tc.function.arguments,
116
116
  timestamp: event.timestamp,
117
117
  })) || []));
@@ -191,7 +191,7 @@ export class LiteLLMProvider {
191
191
  id: tc.id,
192
192
  type: tc.type,
193
193
  function: {
194
- name: tc.function.name,
194
+ name: fixToolFunctionName(tc.function.name),
195
195
  arguments: typeof tc.function.arguments === 'string'
196
196
  ? tc.function.arguments
197
197
  : JSON.stringify(tc.function.arguments),
@@ -216,7 +216,7 @@ export class LiteLLMProvider {
216
216
  litellmRequest.tools = request.tools.map((tool) => ({
217
217
  type: 'function',
218
218
  function: {
219
- name: getValidToolName(tool.id),
219
+ name: fixToolFunctionName(tool.id),
220
220
  description: tool.description,
221
221
  parameters: tool.parameters,
222
222
  },
@@ -378,7 +378,7 @@ export const LiteLLM = {
378
378
  });
379
379
  },
380
380
  };
381
- const getValidToolName = (toolId) => {
381
+ const fixToolFunctionName = (toolId) => {
382
382
  const match = toolId.match(/^[a-zA-Z0-9_-]+/);
383
383
  return match ? match[0] : 'invalid_tool_name';
384
384
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looopy-ai/core",
3
- "version": "2.1.19",
3
+ "version": "2.1.20",
4
4
  "description": "RxJS-based AI agent framework",
5
5
  "repository": {
6
6
  "url": "https://github.com/looopy-ai/lib"