Skip to main content

Overview

Use withTask(options, fn) to mark a discrete step within a workflow. Tasks are automatically linked to their parent workflow or agent.

Signature

Basic Usage

With Metadata

Within a Workflow

Error Handling

Parameters

string
required
Task display name for identification in the Keywords AI dashboard
number
Version number for tracking task iterations
Record<string, any>
Custom metadata to associate with the task

Return Value

Returns a Promise that resolves to the return value of the provided function.

Best Practices

  • Use tasks for discrete, measurable operations within workflows
  • Name tasks clearly to reflect their purpose
  • Nest tasks within workflows or agents for proper hierarchy
  • Tasks automatically capture timing and error information