In short: a long-running AI agent works on one task over hours or days: it waits for an approval, resumes after a reply, picks up where a previous session stopped, and keeps notes in memory. Each pause is a chance for its picture of the world to go out of date. Test these agents with cases that pause and resume, change the records while the agent waits, update a fact it remembered, kill and restart the run, and move the clock forward. The pass rule is the same as for any agent that writes: read the records after the run, and check that the agent acted on the current state, not an old one.
Short agent tasks start and finish in one go. Long-running and stateful agents don't, and the errors that matter for them happen between the steps. This guide covers which cases to add and what to check. For agents that hand work to other agents, see how to test multi-agent handoffs; for approval steps alone, see testing human-in-the-loop AI agents.
What makes an agent long-running or stateful?
Any one of these:
| Trait | Example |
|---|---|
| It waits | A purchase request sits for two days until a manager approves it |
| It resumes | A claim agent continues when the customer sends the missing document |
| It remembers | A support agent keeps notes about a customer across conversations |
| It spans sessions | A finance agent closes the month over several runs |
| It carries a plan | A migration agent works through a list of 400 records in batches |
What these share: the agent decides at step 10 using something it learned at step 2. If that thing changed in between, the decision is wrong even though every step looks fine on its own.
Which errors are specific to long-running agents?
- Stale state. The agent acts on a value that was true when it read it, not now. The supplier's price changed while the request waited for approval; the agent orders at the old price.
- Superseded memory. The customer said "ship to the Berlin office", then later "ship to Munich". The agent's memory has both and uses the first.
- Lost constraints. A rule from the start of the task ("don't exceed the approved budget") is gone after the context is shortened or summarised.
- Duplicate work on resume. The run restarts after a crash and repeats a write it already made. See duplicate writes.
- Expired permissions. An approval, a token or a session that was valid when the run started has lapsed by the time it writes.
- Half-finished batches. The run stops at record 212 of 400 and nobody knows which records are done. See AI agent partial failures.
What does research say about agents and changing state?
Two 2026 benchmarks look at this directly.
StateMemBench (Fan et al., University of Illinois Urbana-Champaign, August 2026) builds 234 multi-session scenarios in which facts, rules and decisions are revised over time, and scores whether an answer reflects the current state or a superseded one. The authors define state drift as acting on a stale version of the state even when the current value is in context, and report that the task is hard for existing memory systems, retrieval baselines and long-context baselines. Their own state-first method improved current-state accuracy from 0.205 to 0.363 on one model: better, and still far from reliable.
MemoryArena (He et al., Stanford and others, February 2026) tests agents on multi-session tasks where later steps depend on what the agent learned earlier. Agents that score near the top on existing long-context memory benchmarks performed poorly there. A memory score from a recall test does not tell you how the agent will act on day three of a task.
EnterpriseOps-Gym (ServiceNow Research, March 2026) points the same way for business systems: across 1,150 tasks with persistent state changes, the best of 14 models completed 37.4%.
Which test cases should a long-running agent have?
Add these on top of your normal cases:
| Case | How to set it up | Pass rule |
|---|---|---|
| Pause and resume | Stop the run at the approval step, resume it later | Continues from the right step; no repeated writes |
| Change while waiting | Edit the record (price, address, quantity) during the pause | Uses the new value or asks; doesn't use the old one silently |
| Superseded fact | Give a fact, then correct it in a later message or session | Acts on the correction |
| Kill and restart | Stop the process in the middle of a write step, start it again | One record per write, and a clear status for the rest |
| Time passes | Move the test clock past an approval or token expiry | Re-checks or asks again; doesn't write on an expired approval |
| Long batch | Run a batch large enough to need several sessions | Every record handled once; a list of what's done and what isn't |
| Constraint after summarising | Make the run long enough that early context gets shortened | The rule from the start still holds at the end |
Each case needs an expected end state, read back from the system after the run, as for any write. See what did your AI agent change.
How do you test memory without testing the whole agent?
Split it into two checks:
- Store. After a session, read the agent's memory directly: did it save the fact, and did it mark the old fact as replaced?
- Use. In the next session, give a task that depends on the fact and check the record it writes.
A memory that stores correctly and is used wrongly is a different bug from one that stores the wrong thing. You need both checks to tell them apart.
What test environment do you need?
The same sandbox as for other write tests, plus three controls:
- A test clock you can move forward, so you don't wait two days for an approval to expire.
- A way to edit records mid-run, so you can change the world while the agent waits.
- A way to stop and restart the run at a chosen step.
The AI agent test environment post covers sandbox, seed data and reset.
Example: a purchase request that waits (illustrative)
A procurement agent creates a purchase request for 50 monitors, sends it for approval and waits. The test changes three things during the wait: the supplier's price goes up, the requested quantity is cut to 40 by the requester, and the approval comes back after the approver's delegation has expired.
The pass rule: the agent writes no purchase order on the expired approval, flags the price change, and the request shows 40 units, not 50. A version of the agent that only reads the request once at the start passes every short test and fails all three checks here. The example is fictional.
How Agentiqa fits
Agentiqa is an AI Quality System for production AI agents. With Agentiqa, you describe each task in plain words. When you rerun the failed tasks, AI Quality Manager reports a step as a regression only if it fails again. Unconfirmed failures are listed separately.
First release gates are live within 7 minutes; for enterprise teams, an Agentiqa engineer sets up the gates on the riskiest tasks over a 3-day rollout.
FAQ
How do you test a long-running AI agent?
Add cases that pause and resume the run, change records while it waits, correct facts it remembered, restart it mid-write and move the clock forward. Then read back the records and check it acted on the current state.
What is state drift in AI agents?
Acting on an out-of-date version of a fact, rule or record, even when the current version is available. It is a key error type for agents that wait or work across sessions.
How do I test AI agent memory?
Check storing and using separately: read the memory after a session, then give a task in the next session that depends on it and check the record it writes.
How do I stop a resumed agent from repeating a write?
Give each write a key that stays the same across retries and restarts, and test it by killing the run in the middle of a write and starting it again.
Do I need to wait days to test approval timeouts?
No. Use a test clock you can move forward, and test both sides: an approval just before it expires and just after.
Is a memory benchmark score enough?
No. Benchmarks score recall on their own tasks. Your cases need to check what the agent writes in your systems when the facts change.
Sources
- Fan, Liu, Yang, Ouyang and Han (University of Illinois Urbana-Champaign), "Can Agent Memory Systems Track Evolving State?" (StateMemBench), August 2026. arXiv:2608.19652. 234 multi-session scenarios; state tracking hard for memory systems, retrieval and long-context baselines; StateMem improved current-state accuracy from 0.205 to 0.363 on DeepSeek-V4-Flash. Read 21 November 2026.
- He, Wang, Zhi et al. (Stanford, UCSD and others), "Benchmarking Agent Memory in Interdependent Multi-Session Agentic Tasks" (MemoryArena), February 2026. arXiv:2602.16313. Agents near-saturated on existing long-context memory benchmarks performed poorly on interdependent multi-session tasks. Read 21 November 2026.
- Malay, Nayak, Nair et al. (ServiceNow Research), "EnterpriseOps-Gym", March 2026. arXiv:2603.13594. 1,150 tasks with persistent state changes; best of 14 models 37.4% (Claude Opus 4.5). Read 21 November 2026.
Next step
List the tasks where your agent waits, resumes or remembers, and for each one write down what can change during the wait. If you build vertical agents and want to turn those cases into release gates, we can go through them with you in 20 minutes.
