keepcalculator

06 Numbers and Powers

AI Agent Paused: Choose the Right State to Resume

Card No. 06·6148 · Updated · Standard formula, shown below

Progress 50.0 %
Estimated remaining
30 min
Result
Elapsed time
30 min
You entered
Completed steps
5 count
You entered
You enter
Elapsed time, Completed steps, Total steps
You get
Progress, Estimated remaining
Rounding
1 dp · 0 dp

When an AI agent pauses mid-task, the right state to resume from is the last checkpoint that captures all completed work and the exact next action, not the last saved snapshot. This article explains how to identify that state, why it matters, and how to implement it in your own agent workflows.

Formula

Progress percentage = (completed steps / total steps) × 100. Estimated remaining time = (elapsed time / completed steps) × (total steps − completed steps).

Variables: c = completed steps, s = total steps, t = elapsed minutes. All units are as entered; the formula assumes each step takes roughly the same time.

Worked Example

Using defaults: c = 5, s = 10, t = 30. Progress = (5 / 10) × 100 = 50%. Estimated remaining = (30 / 5) × (10 − 5) = 6 × 5 = 30 minutes. The calculator shows 50% and 30 min.

Background: What “Paused� Means for AI Agents

AI agents—autonomous programs that execute multi-step tasks—often pause due to API limits, user approval requests, timeouts, or system restarts. The challenge is resuming without losing work or repeating actions. Unlike a human who remembers context, an agent must store its state externally or reconstruct it from logs.

State typically includes: the current step index, accumulated results, variables, and any partial outputs. Without a proper resume strategy, an agent might start over, duplicate side effects (e.g., sending emails twice), or produce inconsistent results.

How State Persistence Works

Modern agent frameworks use three main approaches: checkpointing (saving full state to disk or database), event sourcing (recording every action as an event), and idempotent operations (making actions safe to repeat). Checkpointing is simplest but can be heavy; event sourcing allows replay; idempotency ensures that even if you resume from an older state, re-running an action (like a payment charge) has no duplicate effect.

For example, a web-scraping agent might save the last URL and the data extracted so far. On resume, it re-opens the URL and continues from the next page. If it only saved the data but not the URL, it would need to re-scan from the start.

How to Choose the Right Resume State

The correct state is the one that minimizes wasted work while ensuring correctness. Follow these steps:

  • Identify the atomic unit – what is the smallest step that cannot be safely split? For a data pipeline, that might be a single file. For a chat agent, a single turn.
  • Save after each atomic unit – not just at the end. This gives you the finest resume granularity.
  • Include the next action – store a pointer to what comes next, not just what is done. This avoids re-deriving the plan.
  • Store all context needed for that next action – variables, API tokens, temporary files, and any user inputs.
  • Validate the state on load – check that files exist, tokens are still valid, and the environment hasn’t changed.

If the agent paused mid-step (e.g., after sending a request but before receiving a response), the safest resume point is before that step, provided the operation is idempotent. If not, you must record the step as completed and handle the missing response.

Common Problems and Misconceptions

A frequent mistake is resuming from the last saved snapshot instead of the last successful step. If a snapshot is taken after step 3 but before step 4, and step 4 failed, resuming from that snapshot will re-run step 4—which is correct only if step 4 is idempotent. Otherwise, you might duplicate its effects.

Another issue: time-based resume. Some agents store “elapsed time� and try to continue after a pause, but time is not a reliable indicator of progress. Use step counts or event logs instead.

A common misconception is that you need to save the entire conversation or state. In practice, you only need the minimal context required to continue. Over-saving can cause memory bloat and slow down resume.

Comparing Resume Strategies

Checkpointing is fast to implement and works well for deterministic tasks. Event sourcing offers better auditability and allows you to roll back to any point, but requires more storage and replay logic. Idempotency alone doesn’t give you a resume point—it just makes repeating actions safe, so you can combine it with any strategy.

For long-running tasks (hours or days), checkpointing every few minutes is typical. For interactive agents, event sourcing is often better because it lets you “rewind� to a specific user message. For tasks with side effects (payments, emails), idempotency keys are essential regardless of the strategy.

Costs and Trade-offs

More frequent checkpoints mean higher storage and I/O costs, but less wasted work on resume. Event sourcing can be expensive in terms of storage and CPU to replay events. Idempotency keys add a small overhead per operation but save you from costly duplicates. The right balance depends on your task’s failure rate and the cost of redoing a step.

For example, if each step takes 1 minute and costs $0.01 in API calls, checkpointing every 10 steps means you lose at most 10 minutes and $0.10 on failure. If you checkpoint every step, you lose nothing but write 10× more state.

Safety and Best Practices

Always test resume logic with simulated failures. Ensure that your state storage is transactional—either the state is fully saved or not at all. Never resume from a state that might be corrupt; validate checksums or schema versions. For operations with external side effects, use idempotency keys and log the key with each action. If you are unsure whether an action is idempotent, assume it is not and design accordingly.

Frequently Asked Questions

Q: Can I resume an AI agent from a saved conversation log?
Yes, if the log contains all variables and the next step. But conversation logs often omit internal state like API tokens or temporary files, so you may need to augment them.

Q: What if the agent paused due to an API timeout?
Resume from the step that timed out, but first check if the API actually processed the request. If it did, mark the step as complete; if not, re-run it.

Q: How do I know if an operation is idempotent?
An operation is idempotent if repeating it with the same input produces the same result and no additional side effects. For example, setting a value is idempotent; incrementing a counter is not.

Q: Is it better to save state in memory or on disk?
Memory is faster but lost on crash. Disk is persistent but slower. Use memory for short pauses and disk for long ones, or use a database for both.

Q: Can I resume an agent that was killed abruptly?
Only if you have a checkpoint or event log that was saved before the kill. If not, you must restart from the beginning or use external logs to reconstruct state.

Related

Formula used
in t | Elapsed time | min | 30 | 0 | 1440
in c | Completed steps | count | 5 | 0 | 1000
in s | Total steps | count | 10 | 1 | 1000
out pct | Progress | % | (c / s) * 100 | 1
out eta | Estimated remaining | min | t / c * (s - c) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →