chore: improve error logging

This commit is contained in:
Simon
2026-02-25 16:13:39 +08:00
parent d913dd7bd0
commit 49bdc70c78

View File

@@ -1,6 +1,8 @@
/** /**
* OpenAI Client implementation * OpenAI Client implementation
*/ */
import * as z from 'zod'
import { InvokeError, InvokeErrorType } from './errors' import { InvokeError, InvokeErrorType } from './errors'
import type { InvokeOptions, InvokeResult, LLMClient, LLMConfig, Message, Tool } from './types' import type { InvokeOptions, InvokeResult, LLMClient, LLMConfig, Message, Tool } from './types'
import { modelPatch, zodToOpenAITool } from './utils' import { modelPatch, zodToOpenAITool } from './utils'
@@ -182,7 +184,7 @@ export class OpenAIClient implements LLMClient {
// Validate with schema // Validate with schema
const validation = tool.inputSchema.safeParse(parsedArgs) const validation = tool.inputSchema.safeParse(parsedArgs)
if (!validation.success) { if (!validation.success) {
console.error(validation.error) console.error(z.prettifyError(validation.error))
throw new InvokeError( throw new InvokeError(
InvokeErrorType.INVALID_TOOL_ARGS, InvokeErrorType.INVALID_TOOL_ARGS,
'Tool arguments validation failed', 'Tool arguments validation failed',