{"record":{"id":"17cac288a0c1c37a","repo":"mastra-ai/mastra","slug":"tool-params-id-does-not-have-an-execute-functio","errorCode":null,"errorMessage":"Tool ${params.id} does not have an execute function","messagePattern":"Tool (.+?) does not have an execute function","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/evented/workflow.ts","lineNumber":690,"sourceCode":"    scorers: toolOpts?.scorers,\n    metadata: toolOpts?.metadata,\n    execute: async ({\n      inputData,\n      mastra,\n      requestContext,\n      suspend,\n      resumeData,\n      runId,\n      workflowId,\n      state,\n      setState,\n      abortSignal,\n      ...obsFields\n    }) => {\n      const observabilityContext = resolveObservabilityContext(obsFields);\n      // Tools receive (input, context) - just call the tool's execute\n      if (!params.execute) {\n        throw new Error(`Tool ${params.id} does not have an execute function`);\n      }\n\n      // Build context matching ToolExecutionContext structure\n      const context = {\n        mastra,\n        requestContext,\n        ...observabilityContext,\n        abortSignal,\n        workflow: {\n          runId,\n          workflowId,\n          state,\n          setState,\n          suspend,\n          resumeData,\n        },\n      };\n","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/evented/workflow.ts#L672-L708","documentation":"This error is thrown at execution time when the tool-wrapped step runs: the step body checks params.execute and throws if the tool has no execute function. The schema guard (1902) runs at creation, but a tool with schemas yet no execute only fails when the step actually executes.","triggerScenarios":"Executing a workflow containing a step built via createStep(tool) where tool.execute is undefined — e.g. a tool declaration missing execute, a 'toolset' stub, or a conditionally-attached execute that was never assigned.","commonSituations":"Abstract/base tool classes where subclasses must implement execute but the base instance was registered; tools used purely for schema inference; mocks in tests lacking execute.","solutions":["Implement execute on the tool so it returns the tool's result.","If the tool is only meant for descriptions/schema, replace the workflow step with a plain StepParams step implementing the logic.","Add a startup assertion (typeof tool.execute === 'function') to catch the missing execute before a run."],"exampleFix":"// before\nconst tool = { id: 'sum', inputSchema: z.object({ a: z.number(), b: z.number() }), outputSchema: z.object({ r: z.number() }) };\ncreateStep(tool);\n\n// after\nconst tool = {\n  id: 'sum',\n  inputSchema: z.object({ a: z.number(), b: z.number() }),\n  outputSchema: z.object({ r: z.number() }),\n  execute: async ({ context }) => ({ r: context.a + context.b }),\n};\ncreateStep(tool);","handlingStrategy":"validation","validationCode":"function assertToolExecutable(tool: { id: string; execute?: unknown }) {\n  if (typeof tool.execute !== 'function') {\n    throw new Error(`Tool ${tool.id} must implement execute before being used in a workflow`);\n  }\n}","typeGuard":"const hasExecute = (t: any): t is { execute: (...args: any[]) => any } =>\n  typeof t?.execute === 'function';","tryCatchPattern":"try {\n  await runStep(toolStep, input);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not have an execute function')) {\n    // fall back or fail fast with tool id context\n  }\n  throw e;\n}","preventionTips":["Never register abstract/base tool instances that expect subclasses to define execute.","Validate the full tool surface (schemas + execute) at registration/boot time.","Avoid casting tools to any, which hides the missing execute from the type checker."],"tags":["tool","runtime","execute","workflow"],"backgroundTag":"tool-missing-execute-function","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}