How Durable Execution works in Icepick
mainIcepick provides durable execution by using a durable task queue (Hatchet). This means every task is stored in a database, allowing agents to recover from failures (like hardware crashes) or wait for long-running external events without consuming resources.
The Event Log and Replay Model
When an agent executes, Icepick maintains an event log of all completed steps. If a crash occurs, Icepick automatically replays the execution history to reach the last known successful state.
Example Workflow:
Start search_documents->Finish search_documents(Logged)Start get_document->Finish get_document(Logged)Start extract_from_document... [CRASH OCCURS HERE]
Recovery Process: Upon restart, Icepick replays the logged events:
Start search_documents(replayed)Finish search_documents(replayed)Start get_document(replayed)Finish get_document(replayed)Start extract_from_document(replayed) -> Resumes normal execution
Best Practices for Durable Agents
To ensure the replay model works correctly, agents must follow these rules:
- Stateless Reducers: Agents should be stateless and have no side effects. They should not depend on external API calls, database calls, or local disk calls directly within the agent function. Instead, all state should be determined by the results of their tool calls.
- All work as tasks/tools: Every unit of work should be invoked as a task or a tool call so that it can be captured in the event log.
- Own your data lookups: Do not allow unconstrained tool calling for data lookups. Tools should validate permissions and separate data lookup from LLM calls for security.