icepick.tool method creates a new tool that can be used by agents in Icepick.
Quick Reference
- Main execution methods:
run(),runAndWait(),runNoWait() - Scheduling methods:
schedule(),delay(),cron()
Usage Example
Parameters
Concurrency Type
Returns
Theicepick.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 tooloptions?:RunOpts- Optional configuration for this tool run
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 tooloptions?:RunOpts- Optional configuration for this tool run
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 tooloptions?:RunOpts- Optional configuration for this tool run
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 triggeredinput:z.infer<InputSchema>- The input data for the tooloptions?:RunOpts- Optional configuration for this tool run
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 runinput:z.infer<InputSchema>- The input data for the tooloptions?:RunOpts- Optional configuration for this tool run
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 scheduleexpression:string- The cron expression defining the scheduleinput:z.infer<InputSchema>- The input data for the tooloptions?:RunOpts- Optional configuration for this tool run
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 optionalctx 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
Related
icepick.agent- Create agents that can use toolsicepick.toolbox- Create collections of tools for agents to use- Hatchet Documentation - Learn more about the underlying workflow engine

