{"record":{"id":"68db31447e563ce7","repo":"mastra-ai/mastra","slug":"invalid-input-expected-stepparams-agent-toolste","errorCode":null,"errorMessage":"Invalid input: expected StepParams, Agent, ToolStep, or Processor","messagePattern":"Invalid input: expected StepParams, Agent, ToolStep, or Processor","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/evented/workflow.ts","lineNumber":361,"sourceCode":"  }\n\n  if (isToolStep(params)) {\n    return createStepFromTool(params, agentOrToolOptions);\n  }\n\n  if (isProcessor(params)) {\n    const step = createStepFromProcessor(params) as ReturnType<typeof createStepFromProcessor> & {\n      providesSkillDiscovery?: Processor['providesSkillDiscovery'];\n    };\n    step.providesSkillDiscovery = params.providesSkillDiscovery;\n    return step;\n  }\n\n  if (isStepParams(params)) {\n    return createStepFromParams(params);\n  }\n\n  throw new Error('Invalid input: expected StepParams, Agent, ToolStep, or Processor');\n}\n\n// ============================================\n// Internal Implementations\n// ============================================\n\nfunction createStepFromParams<\n  TStepId extends string,\n  TStateSchema extends PublicSchema<any> | undefined,\n  TInputSchema extends PublicSchema<any>,\n  TOutputSchema extends PublicSchema<any>,\n  TResumeSchema extends PublicSchema<any> | undefined = undefined,\n  TSuspendSchema extends PublicSchema<any> | undefined = undefined,\n  TRequestContextSchema extends PublicSchema<any> | undefined = undefined,\n>(\n  params: StepParams<\n    TStepId,\n    TStateSchema,","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/evented/workflow.ts#L343-L379","documentation":"createStep() accepts four kinds of inputs: StepParams object, an Agent, a ToolStep, or a Processor. It probes each with type guards (isAgentCompatible, isToolStep, isProcessor, isStepParams) and throws this plain Error when none match, meaning the argument is not one of the supported shapes (e.g. undefined, a plain function, or a malformed object).","triggerScenarios":"Calling createStep(x) where x is undefined/null (e.g. an agent failed to import), a bare execute function instead of a params object, an object missing the identifying fields all guards check (id, execute, model, processInput, etc.), or passing a Tool whose shape differs from ToolStep.","commonSituations":"Circular import leaving an agent undefined at module init; passing a legacy tool or custom wrapper object not matching the expected interface; typos like createStep(executeFn); refactors after v0.x -> v1 where step definitions changed shape.","solutions":["Inspect the value passed to createStep and confirm it is an Agent, ToolStep (tool with inputSchema/outputSchema/execute), Processor, or a StepParams object with id/inputSchema/outputSchema/execute.","Fix imports so the agent/tool is defined before createStep runs (watch for circular dependencies producing undefined).","If wrapping a custom object, convert it to a StepParams object literal with an execute function.","Log the argument (console.log(typeof params, params)) right before createStep to see what actually arrived."],"exampleFix":"// before\ncreateStep(myHandlerFunction);\n\n// after\ncreateStep({\n  id: 'myStep',\n  inputSchema: z.object({ prompt: z.string() }),\n  outputSchema: z.object({ text: z.string() }),\n  execute: async ({ inputData }) => ({ text: inputData.prompt }),\n});","handlingStrategy":"type-guard","validationCode":"function isCreateStepInput(x: unknown): boolean {\n  return !!x && typeof x === 'object' && (\n    'id' in x || 'execute' in x || 'model' in x || 'processInput' in x\n  );\n}","typeGuard":"const isStepCandidate = (x: unknown): x is Record<string, unknown> =>\n  typeof x === 'object' && x !== null && ('id' in x || 'execute' in x);","tryCatchPattern":"let step;\ntry {\n  step = createStep(candidate as any);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Invalid input: expected StepParams')) {\n    throw new Error(`createStep received invalid input: ${JSON.stringify(candidate)}`);\n  }\n  throw e;\n}","preventionTips":["Always pass typed values (Agent | Tool | Processor | StepParams), never unions collapsed to any/unknown.","Check imports for circular dependencies that leave agents/tools undefined at module evaluation time.","Enable TypeScript strict mode so malformed step definitions fail at compile time."],"tags":["workflow","validation","api-misuse","typescript"],"backgroundTag":"invalid-create-step-input","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}