FlowiseAI/Flowise · error · Error
Received tool input did not match expected schema: ${JSON.st
Error message
Received tool input did not match expected schema: ${JSON.stringify(arg)} What it means
Thrown inside ChatflowTool StructuredTool._call when parseWithTypeConversion(this.schema, arg) rejects. Identical to error 347 for the agentflow variant: arg is the LLM-supplied tool call input, this.schema is a zod schema, and the raw arg is JSON-stringified into the message so the caller can see what the model sent.
Source
Thrown at packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts:292
this.overrideConfig = overrideConfig
this.returnDirect = returnDirect
}
async call(
arg: z.infer<typeof this.schema>,
configArg?: RunnableConfig | Callbacks,
tags?: string[],
flowConfig?: { sessionId?: string; chatId?: string; input?: string }
): Promise<string> {
const config = parseCallbackConfigArg(configArg)
if (config.runName === undefined) {
config.runName = this.name
}
let parsed
try {
parsed = await parseWithTypeConversion(this.schema, arg)
} catch (e) {
throw new Error(`Received tool input did not match expected schema: ${JSON.stringify(arg)}`)
}
const callbackManager_ = await CallbackManager.configure(
config.callbacks,
this.callbacks,
config.tags || tags,
this.tags,
config.metadata,
this.metadata,
{ verbose: this.verbose }
)
const runManager = await callbackManager_?.handleToolStart(
this.toJSON(),
typeof parsed === 'string' ? parsed : JSON.stringify(parsed),
undefined,
undefined,
undefined,
undefined,
config.runNameView on GitHub (pinned to abe4a8601a)
Solutions
- Inspect the JSON-stringified arg to see what the model sent.
- Improve tool description and add few-shot examples.
- Loosen the schema where sensible; upgrade to a stronger tool-calling model if errors persist.
Example fix
// before
try {
parsed = await parseWithTypeConversion(this.schema, arg)
} catch (e) {
throw new Error(`Received tool input did not match expected schema: ${JSON.stringify(arg)}`)
}
// after
try {
parsed = await parseWithTypeConversion(this.schema, arg)
} catch (e) {
const reason = e instanceof Error ? e.message : String(e)
throw new Error(`Received tool input did not match expected schema: ${JSON.stringify(arg)} (reason: ${reason})`)
} Defensive patterns
Strategy: try-catch
Validate before calling
function preflightSchema(schema: z.ZodTypeAny, arg: unknown) {
const r = schema.safeParse(arg)
if (!r.success) throw new Error(`Preflight schema violation: ${r.error.message}`)
} Type guard
function looksLikeToolArg(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null && !Array.isArray(v)
} Try / catch
try {
return await chatflowTool.invoke(arg)
} catch (e) {
const msg = (e as Error).message
if (msg.startsWith('Received tool input did not match')) {
// feed JSON.stringify(arg) back to the model with a corrective prompt
} else throw e
} Prevention
- Provide few-shot examples of correct tool calls in the prompt.
- Keep schemas minimal and additive (optional fields with defaults).
- Prefer models with strong function-calling for StructuredTool-heavy agents.
When it happens
Trigger: LLM emitted JSON-as-string, omitted required fields, sent wrong types, or produced malformed JSON that parseWithTypeConversion cannot coerce.
Common situations: Weaker model with poor tool-calling; schema changed without prompt updates; truncated JSON from a model timeout.
Related errors
- Received tool input did not match expected schema: ${JSON.st
- Received tool input did not match expected schema
- Error parsing Zod Schema: ${exception}
- Received tool input did not match expected schema ${e}
- Unsupported type: ${typeInfo.base}
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/11b71b2add1e6ab0.
Report an issue: GitHub.