Skip to main content

@elizaos/core v1.0.0-beta.51 / TaskWorker

Interface: TaskWorker

Defines the contract for a Task Worker, which is responsible for executing a specific type of task. Task workers are registered with the AgentRuntime and are invoked when a Task of their designated name needs processing. This pattern allows for modular and extensible background task processing.

Properties​

name​

name: string

The unique name of the task type this worker handles. This name links Task instances to this worker.

Defined in​

packages/core/src/types.ts:1522


execute()​

execute: (runtime, options, task) => Promise<void>

The core execution logic for the task. This function is called by the runtime when a task needs to be processed. It receives the AgentRuntime, task-specific options, and the Task object itself.

Parameters​

• runtime: IAgentRuntime

• options

• task: Task

Returns​

Promise<void>

Defined in​

packages/core/src/types.ts:1527


validate()?​

optional validate: (runtime, message, state) => Promise<boolean>

Optional validation function that can be used to determine if a task is valid or should be executed, often based on the current message and state. This might be used by an action or evaluator before creating or queueing a task.

Parameters​

• runtime: IAgentRuntime

• message: Memory

• state: State

Returns​

Promise<boolean>

Defined in​

packages/core/src/types.ts:1537