Workflow.tool()
The .tool() method adds a tool as a declarative step. The tool's own input and output schemas apply, so the previous step's output must satisfy the tool's input schema. Use .map() to transform the data if they don't match.
Unlike wrapping a tool with createStep(), .tool() records a declarative entry in the workflow graph. This makes the workflow portable: the same graph can be serialized and persisted as a dynamic workflow.
Usage exampleUsage example的直接链接
workflow.tool(testTool).commit()
ParametersParameters的直接链接
toolOrId:
options?:
stepOptions?:
ReturnsReturns的直接链接
workflow:
Referencing a tool by IDReferencing a tool by ID的直接链接
Pass a string to reference a registered tool without importing it. The tool must be registered on the Mastra instance when the workflow runs:
workflow.tool('lookup-customer', { retries: 2 }).commit()
Persisting tool stepsPersisting tool steps的直接链接
Workflows built with .tool() serialize to the same declarative entries that dynamic workflows use. Only retries and metadata round-trip through storage. A function-valued scorers option throws an error when the workflow is stored.