{"record":{"id":"bea596025571116f","repo":"FlowiseAI/Flowise","slug":"received-tool-input-did-not-match-expected-schema-bea596","errorCode":null,"errorMessage":"Received tool input did not match expected schema","messagePattern":"Received tool input did not match expected schema","errorType":"validation","errorClass":"ToolInputParsingException","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/tools/CodeInterpreterE2B/CodeInterpreterE2B.ts","lineNumber":164,"sourceCode":"            domainCodeInterpreterE2B: options.domainCodeInterpreterE2B\n        })\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; state?: ICommonObject }\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 ToolInputParsingException(`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":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/CodeInterpreterE2B/CodeInterpreterE2B.ts#L146-L182","documentation":"Thrown inside CodeInterpreterE2B StructuredTool._call when parseWithTypeConversion(this.schema, arg) rejects. Unlike the agentflow/chatflow variants (which throw a plain Error), this one throws ToolInputParsingException with the raw arg passed as the second argument — a LangChain-specific exception that downstream agents can recognize as a 'fix your tool call and retry' signal rather than a fatal error.","triggerScenarios":"LLM emitted a code string where the schema expected an object, omitted required fields (e.g. the code to execute), or sent malformed JSON.","commonSituations":"Schema requires { code: string } but the model sends a bare string; model wraps the payload in extra quotes; switching to a model with weaker function-calling.","solutions":["Inspect JSON.stringify(arg) in the exception to see the actual payload.","Align the tool description with the schema — make the required 'code' field explicit.","Because this is a ToolInputParsingException, let the agent loop retry the tool call after the exception rather than aborting the run."],"exampleFix":"// before\ntry {\n  parsed = await parseWithTypeConversion(this.schema, arg)\n} catch (e) {\n  throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(arg))\n}\n// after: surface the parse reason so the agent can self-correct\ntry {\n  parsed = await parseWithTypeConversion(this.schema, arg)\n} catch (e) {\n  const reason = e instanceof Error ? e.message : String(e)\n  throw new ToolInputParsingException(\n    `Received tool input did not match expected schema (${reason})`,\n    JSON.stringify(arg)\n  )\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":"// ToolInputParsingException is meant to be caught and retried by the agent loop\ntry {\n  return await e2bTool.invoke(arg)\n} catch (e) {\n  if (e instanceof ToolInputParsingException) {\n    // ask the model to correct the payload, then retry once\n  } else throw e\n}","preventionTips":["Treat ToolInputParsingException as a retry signal in the agent loop, not a fatal error.","Make the required 'code' field explicit in the tool description.","Add few-shot examples of well-formed code-interpreter calls."],"tags":["langchain","schema","zod","validation","e2b","llm-input"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}