FlowiseAI/Flowise · error · ToolInputParsingException
Received tool input did not match expected schema
Error message
Received tool input did not match expected schema
What it means
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.
Source
Thrown at packages/components/nodes/tools/CodeInterpreterE2B/CodeInterpreterE2B.ts:164
domainCodeInterpreterE2B: options.domainCodeInterpreterE2B
})
}
async call(
arg: z.infer<typeof this.schema>,
configArg?: RunnableConfig | Callbacks,
tags?: string[],
flowConfig?: { sessionId?: string; chatId?: string; input?: string; state?: ICommonObject }
): 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 ToolInputParsingException(`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 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.
Example fix
// before
try {
parsed = await parseWithTypeConversion(this.schema, arg)
} catch (e) {
throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(arg))
}
// after: surface the parse reason so the agent can self-correct
try {
parsed = await parseWithTypeConversion(this.schema, arg)
} catch (e) {
const reason = e instanceof Error ? e.message : String(e)
throw new ToolInputParsingException(
`Received tool input did not match expected schema (${reason})`,
JSON.stringify(arg)
)
} 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
// ToolInputParsingException is meant to be caught and retried by the agent loop
try {
return await e2bTool.invoke(arg)
} catch (e) {
if (e instanceof ToolInputParsingException) {
// ask the model to correct the payload, then retry once
} else throw e
} Prevention
- 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.
When it happens
Trigger: LLM emitted a code string where the schema expected an object, omitted required fields (e.g. the code to execute), or sent malformed JSON.
Common situations: 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.
Related errors
- Received tool input did not match expected schema: ${JSON.st
- Received tool input did not match expected schema: ${JSON.st
- 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/bea596025571116f.
Report an issue: GitHub.