Async Long-Running Tool Calls
Handling tool calls that take minutes rather than seconds -- checkpoint-and-suspend patterns, async polling, webhook resumption, SSE progress streaming, durable execution with Temporal and Step Functions, and idempotency requirements for retriable tool invocations.
Overview
Overview
Standard LLM tool use assumes a tool returns inside the inference timeout, typically a few seconds. A data pipeline, batch job, video transcode or fine-tuning run can take five minutes to an hour, and bridging that gap without holding a server connection open takes patterns from both agent orchestration and distributed systems.
Here is one such request from start to finish. Five parties take part: the user, the agent graph, a checkpointer that saves the graph's state so it can stop and pick up later, the external pipeline, and a webhook handler, the HTTP endpoint the pipeline calls when it is done.
- The user sends a request to the agent graph.
- The agent stores an idempotency key in the checkpointer. The key is a unique id that lets the pipeline service recognize a repeat of the same request.
- The agent starts the job on the external pipeline, passing the idempotency key, and the pipeline returns a job_id.
- The agent stores the job_id with status running in the checkpointer and tells the user the pipeline has started. The connection is released.
- The pipeline runs for minutes. When it finishes, it POSTs the job_id and the result to the webhook handler.
- The webhook handler writes the result into the checkpoint with update_state(result) and calls invoke(None) on the same thread_id.
- The agent continues with the result, and the user sees it.
Interview questions
- How do you handle long-running asynchronous tool calls? For example, if an agent triggers a data pipeline that takes 5 minutes, how do you manage the agent's state and the user experience?
- What happens if the agent process crashes while waiting for the 5-minute pipeline? How do you recover?
- How would you design the user experience so the user knows what is happening during a 5-minute wait?
Sign up free to read the full topic
More Agentic AI topics
- AI Gateways: Routing, Fallback, Caching & Metering
- Autoscaling LLM Inference on Kubernetes
- Browser & Computer-use Agents
- Context Engineering & Prompt Design
- Context Window Management for Persistent Agents
- Designing Tools a Model Calls Well
- Distillation & Small Models
- Embeddings & Vector Search
- Evaluating Agents: Task Suites, Trajectories & Regression Gates
- Evaluating RAG & Catching Hallucinations
- Fine-tuning LLMs: SFT, LoRA/QLoRA & Preference Tuning
- Guardrails & Prompt Injection Defense
Start free on Cariara · Coding problems · System design studio