Async Job

Handle long-running operations with job IDs and polling.

category: Tool Execution
arcade.dev/patterns

Context

Operations that take minutes or longer.

Problem

Long operations can't block the conversation; agents need to check progress.

Solution

Async job pattern:
- Start: Return job_id immediately
- Poll: check_job_status(job_id)
- Result: get_job_result(job_id)
- Cancel: cancel_job(job_id) if needed

Examples

Python
@tool
def generate_report(params: ReportParams) -> JobHandle:
    """Start report generation. Returns job ID for polling.
    
    This may take several minutes. Use check_job_status()
    to monitor progress and get_job_result() when complete.
    """
    job_id = report_service.start(params)
    return JobHandle(
        job_id=job_id,
        status_tool="check_job_status",
        result_tool="get_job_result",
        estimated_minutes=5
    )

@tool
def check_job_status(job_id: str) -> JobStatus:
    """Check if an async job has completed."""
    return job_service.status(job_id)

Considerations

  • Include estimated completion time
  • Provide progress updates if possible
  • Return clear next steps in the job handle

Related Patterns

More in Tool Execution