{"record":{"id":"88527343d8ad5a1c","repo":"mastra-ai/mastra","slug":"invalid-input-expected-stepparams-agent-toolste-885273","errorCode":null,"errorMessage":"Invalid input: expected StepParams, Agent, ToolStep, or Processor","messagePattern":"Invalid input: expected StepParams, Agent, ToolStep, or Processor","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/workflow.ts","lineNumber":453,"sourceCode":"  if (isToolStep(params)) {\n    return createStepFromTool(params, agentOrToolOptions);\n  }\n\n  // StepParams check must come before isProcessor since both have 'id'\n  // StepParams always has 'execute', while Processor has processor methods\n  if (isStepParams(params)) {\n    return createStepFromParams(params);\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  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>(\n  params: StepParams<TStepId, TStateSchema, TInputSchema, TOutputSchema, TResumeSchema, TSuspendSchema>,\n): Step<\n  TStepId,\n  TStateSchema extends PublicSchema<any> ? InferPublicSchema<TStateSchema> : unknown,","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/workflow.ts#L435-L471","documentation":"createStep only accepts plain StepParams, an Agent instance, a ToolStep, or a Processor. Anything else (plain functions, tool definitions not wrapped as ToolStep, strings, undefined from bad imports) falls through all instanceof/shape checks and reaches this final throw. It is a guard against passing unsupported step inputs to workflow.createStep.","triggerScenarios":"Passing a raw tool object instead of a ToolStep; passing a function; passing undefined/null due to a failed import or circular dependency; passing a Processor created elsewhere but mutated; passing an object that almost matches StepParams but with misspelled keys like 'executes' instead of 'execute'.","commonSituations":"Migrating between Mastra versions where step param shapes changed; forgetting to wrap an AI SDK tool; typos in imports causing undefined values; trying to reuse an agent created with a different base class.","solutions":["Verify the value passed is one of: StepParams object, Agent instance, ToolStep, or Processor.","If passing a tool, wrap it as a ToolStep (e.g. via createTool from the right package).","Log the value and its constructor before createStep to spot undefined/mistyped inputs.","Fix broken imports (check for circular deps returning undefined).","Update to matching @mastra/core versions across packages so instanceof checks pass."],"exampleFix":"// before\nworkflow.createStep(myTool);\n// after\nimport { createTool } from '@mastra/core/tools';\nconst toolStep = createTool({ id: 'myTool', ... });\nworkflow.createStep(toolStep);","handlingStrategy":"type-guard","validationCode":"if (params == null) throw new TypeError('createStep received undefined — check imports');\nconst ok = typeof params === 'object' && ('execute' in (params as object) || params instanceof Agent || params instanceof Processor);","typeGuard":"function isStepParams(v: unknown): v is StepParams {\n  return typeof v === 'object' && v !== null && 'execute' in v && typeof (v as StepParams).execute === 'function';\n}","tryCatchPattern":"try {\n  workflow.createStep(candidate as StepParams);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Invalid input: expected StepParams')) {\n    console.error('Bad step input:', candidate?.constructor?.name);\n  } else throw e;\n}","preventionTips":["Wrap raw tools with createTool.","Verify imports resolve to non-undefined.","Keep @mastra/core versions aligned.","Check step param shape after upgrading versions."],"tags":["workflow","types","configuration"],"backgroundTag":"invalid-step-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}