Skip to content

Commit 0ee90b1

Browse files
fix: remove tools that aren't implemented with valid Zod schemas
- Remove all tool passing to AI SDK since built-in tools from JSON don't have proper Zod validation - Tools are now processed server-side only, avoiding zod-to-json-schema conversion errors - This prevents 'Cannot read properties of undefined (reading "typeName")' errors - Functionality is maintained through server-side tool processing (MCP + built-in tools)
1 parent 7fe4694 commit 0ee90b1

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

app/lib/.server/llm/stream-text.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { allowedHTMLElements } from '~/utils/markdown';
88
import { LLMManager } from '~/lib/modules/llm/manager';
99
import { createScopedLogger } from '~/utils/logger';
1010
import { createFilesContext, extractPropertiesFromMessage } from './utils';
11-
import { BuiltInToolService } from '~/lib/services/builtInToolService';
1211

1312
export type Messages = Message[];
1413

@@ -210,16 +209,16 @@ Use these preferences when creating UI components, styling code, or suggesting d
210209

211210
logger.info(`Sending llm call to ${provider.name} with model ${modelDetails.name}`);
212211

213-
let allTools = { ...options?.tools };
214-
const builtInToolService = BuiltInToolService.getInstance();
215-
const builtInTools = builtInToolService.toolsWithoutExecute;
212+
/*
213+
* Only pass tools that are properly implemented with valid Zod schemas.
214+
* Built-in tools from JSON don't have Zod validation, so we don't pass any tools
215+
* to avoid zod-to-json-schema conversion errors.
216+
*/
217+
const allTools = {};
216218

217-
if (Object.keys(builtInTools).length > 0) {
218-
allTools = { ...allTools, ...builtInTools };
219-
logger.info(`Added ${Object.keys(builtInTools).length} built-in tools:`, Object.keys(builtInTools));
220-
}
219+
logger.info(`Skipping all tool passing to AI SDK - tools are processed server-side only`);
221220

222-
const hasTools = Object.keys(allTools).length > 0;
221+
const hasTools = false;
223222

224223
return await _streamText({
225224
model: provider.getModelInstance({
@@ -232,6 +231,5 @@ Use these preferences when creating UI components, styling code, or suggesting d
232231
maxTokens: dynamicMaxTokens,
233232
messages: convertToCoreMessages(processedMessages as any),
234233
...(hasTools ? { tools: allTools, toolChoice: 'auto' } : {}),
235-
...options,
236234
});
237235
}

0 commit comments

Comments
 (0)