Resume
Resume agent runs from checkpoints — crash recovery and long-running tasks.
How It Works
AgentForge checkpoints run state after every step. If the process crashes or a run is paused, you can resume by passing the same runId:
// First execution — may crash at step 5
const result = await agent.run({
task: 'Process 1000 records',
runId: 'run_abc123',
});
// Resume — continues from last checkpoint
const resumed = await agent.run({
task: 'Process 1000 records',
runId: 'run_abc123',
});# First execution
result = await agent.run(task="Process 1000 records", run_id="run_abc123")
# Resume
resumed = await agent.run(task="Process 1000 records", run_id="run_abc123")Requirements
Resume requires a persistent state store. The default in-memory store doesn't survive process restarts:
import { RedisStateStore } from '@ahzan-agentforge/core';
const agent = defineAgent({
name: 'resumable-agent',
tools: [myTool],
llm,
systemPrompt: '...',
description: 'Can resume from crashes',
stateStore: new RedisStateStore({ url: 'redis://localhost:6379' }),
});Approval Flow
When the autonomy policy escalates a tool call, the run pauses with awaiting_approval status. Resume it with approve():
const result = await agent.run({ task: 'Delete all old records' });
if (result.status === 'awaiting_approval') {
// Review the pending approval
console.log(result.output); // Description of what needs approval
// Approve and continue
const continued = await agent.approve(result.runId, true);
console.log(continued.status); // "completed"
// Or deny
const denied = await agent.approve(result.runId, false);
console.log(denied.status); // "failed"
}Run ID Format
Run IDs follow the format run_{timestamp}_{nanoid(6)}:
run_1710000000000_abc123If you don't provide a runId, AgentForge generates one automatically.
Next Steps
- State — state store options
- Checkpoint & Resume — state internals