{"record":{"id":"11b71b2add1e6ab0","repo":"FlowiseAI/Flowise","slug":"received-tool-input-did-not-match-expected-schema-11b71b","errorCode":null,"errorMessage":"Received tool input did not match expected schema: ${JSON.stringify(arg)}","messagePattern":"Received tool input did not match expected schema: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts","lineNumber":292,"sourceCode":"        this.overrideConfig = overrideConfig\n        this.returnDirect = returnDirect\n    }\n\n    async call(\n        arg: z.infer<typeof this.schema>,\n        configArg?: RunnableConfig | Callbacks,\n        tags?: string[],\n        flowConfig?: { sessionId?: string; chatId?: string; input?: string }\n    ): Promise<string> {\n        const config = parseCallbackConfigArg(configArg)\n        if (config.runName === undefined) {\n            config.runName = this.name\n        }\n        let parsed\n        try {\n            parsed = await parseWithTypeConversion(this.schema, arg)\n        } catch (e) {\n            throw new Error(`Received tool input did not match expected schema: ${JSON.stringify(arg)}`)\n        }\n        const callbackManager_ = await CallbackManager.configure(\n            config.callbacks,\n            this.callbacks,\n            config.tags || tags,\n            this.tags,\n            config.metadata,\n            this.metadata,\n            { verbose: this.verbose }\n        )\n        const runManager = await callbackManager_?.handleToolStart(\n            this.toJSON(),\n            typeof parsed === 'string' ? parsed : JSON.stringify(parsed),\n            undefined,\n            undefined,\n            undefined,\n            undefined,\n            config.runName","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts#L274-L310","documentation":"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.","triggerScenarios":"LLM emitted JSON-as-string, omitted required fields, sent wrong types, or produced malformed JSON that parseWithTypeConversion cannot coerce.","commonSituations":"Weaker model with poor tool-calling; schema changed without prompt updates; truncated JSON from a model timeout.","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."],"exampleFix":"// before\ntry {\n  parsed = await parseWithTypeConversion(this.schema, arg)\n} catch (e) {\n  throw new Error(`Received tool input did not match expected schema: ${JSON.stringify(arg)}`)\n}\n// after\ntry {\n  parsed = await parseWithTypeConversion(this.schema, arg)\n} catch (e) {\n  const reason = e instanceof Error ? e.message : String(e)\n  throw new Error(`Received tool input did not match expected schema: ${JSON.stringify(arg)} (reason: ${reason})`)\n}","handlingStrategy":"try-catch","validationCode":"function preflightSchema(schema: z.ZodTypeAny, arg: unknown) {\n  const r = schema.safeParse(arg)\n  if (!r.success) throw new Error(`Preflight schema violation: ${r.error.message}`)\n}","typeGuard":"function looksLikeToolArg(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v)\n}","tryCatchPattern":"try {\n  return await chatflowTool.invoke(arg)\n} catch (e) {\n  const msg = (e as Error).message\n  if (msg.startsWith('Received tool input did not match')) {\n    // feed JSON.stringify(arg) back to the model with a corrective prompt\n  } else throw e\n}","preventionTips":["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."],"tags":["langchain","schema","zod","validation","llm-input"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}