Skip to main content
The icepick.tool method creates a new tool that can be used by agents in Icepick.

Quick Reference

Usage Example

Parameters

Concurrency Type

Returns

The icepick.tool method returns a ToolDeclaration<InputSchema, OutputSchema> & { name: Name } object with the following properties and methods:

Properties

Methods

run(input, options?)

Executes the tool with the given input and waits for completion. Parameters:
  • input: z.infer<InputSchema> - The input data for the tool
  • options?: RunOpts - Optional configuration for this tool run
Returns: Promise<z.infer<OutputSchema>> - A promise that resolves with the tool result Throws: Error if the tool is not bound to a Hatchet client

runAndWait(input, options?)

Alias for run(). Triggers a tool run and waits for the result. Parameters:
  • input: z.infer<InputSchema> - The input data for the tool
  • options?: RunOpts - Optional configuration for this tool run
Returns: Promise<z.infer<OutputSchema>> - A promise that resolves with the tool result

runNoWait(input, options?)

Triggers the tool execution without waiting for completion. Parameters:
  • input: z.infer<InputSchema> - The input data for the tool
  • options?: RunOpts - Optional configuration for this tool run
Returns: Promise<WorkflowRunRef<z.infer<OutputSchema>>> - A WorkflowRunRef containing the run ID and methods to get results and interact with the run Throws: Error if the tool is not bound to a Hatchet client

schedule(enqueueAt, input, options?)

Schedules the tool to run at a specific date and time in the future. Parameters:
  • enqueueAt: Date - The date when the tool should be triggered
  • input: z.infer<InputSchema> - The input data for the tool
  • options?: RunOpts - Optional configuration for this tool run
Returns: Promise<ScheduledWorkflows> - A promise that resolves with the scheduled workflow details Throws: Error if the tool is not bound to a Hatchet client

delay(duration, input, options?)

Schedules the tool to run after a specified delay. Parameters:
  • duration: number - The delay in seconds before the tool should run
  • input: z.infer<InputSchema> - The input data for the tool
  • options?: RunOpts - Optional configuration for this tool run
Returns: Promise<ScheduledWorkflows> - A promise that resolves with the scheduled workflow details Throws: Error if the tool is not bound to a Hatchet client

cron(name, expression, input, options?)

Creates a cron schedule for recurring tool execution. Parameters:
  • name: string - The name of the cron schedule
  • expression: string - The cron expression defining the schedule
  • input: z.infer<InputSchema> - The input data for the tool
  • options?: RunOpts - Optional configuration for this tool run
Returns: Promise<CronWorkflows> - A promise that resolves with the cron workflow details Throws: Error if the tool is not bound to a Hatchet client

RunOpts Type

Context

The optional ctx parameter in the tool function provides access to the Hatchet workflow execution context. When present, it offers comprehensive capabilities for workflow management, logging, and execution control.

Core Properties

Execution Control Methods

Logging & Data Methods