What is a long-running agent?
A long-running agent is an AI agent that works on one task across many context windows, sessions or days, resuming from state kept outside the model, such as progress files, commits or a session log.
Two kinds of agent get called long-running. Build agents work continuously for hours: OpenAI's guide to long-horizon Codex tasks describes a run of about 25 hours that produced about 30,000 lines from a spec. Process agents wait for days between steps: Google's Agent Runtime supports agents that keep state for up to seven days, and Google's ADK guidance shows an onboarding agent pausing while a new hire signs documents and a laptop is delivered.
Both hit the same wall. A context window cannot hold the whole history, containers restart, and a model that resumes after a gap may assume steps happened that did not. A long-running agent is mostly the machinery that solves those three problems.
Patterns the labs publish
An initializer, then increments
Anthropic's "Effective harnesses for long-running agents" (November 2025) has a first agent set up the environment once, and a coding agent make incremental progress each session.
Done is defined up front
A feature list with every item marked failing at the start stops early claims of completion. OpenAI's Codex guide adds a stop-and-fix rule: repair failed checks before the next milestone.
Durable project memory
Progress files, plan files and git commits let a fresh session recover state. OpenAI's guide used four markdown files for spec, plan, runbook and status.
Context resets or compaction
Anthropic's March 2026 harness post found some models wrap up early as they near their context limit, and used fresh sessions with structured handoffs; with a later model, automatic compaction was enough.
A session log outside the window
Anthropic's Managed Agents design keeps the session as a durable event log, so nothing is lost when context is trimmed.
Explicit state machines
Google's ADK guidance (May 2026) tracks progress in persistent session state with named checkpoints, resumes through webhooks, and treats a human approval as a pause.
Cost and oversight
Long runs are not cheap. Anthropic's harness post reports a digital audio workstation build that ran for about 3 hours 50 minutes and cost $124.70 across planning, three build rounds and three QA rounds. Budgets per run, and alerts when a run exceeds them, belong in the design from the start.
Oversight changes shape as well. Nobody approves every step of a 25-hour run, so the checks move to milestones, test results and reviewable artifacts, with a person reading the plan before it starts and the output when it ends.
How Motiontic's engineers apply it
Motiontic's engineers design the state first: what the agent writes down, where it lives, and how a fresh session proves where things stand. Evals pre-seed that state to simulate gaps, such as a delayed approval, and check the agent does not skip a gate when it wakes up.
A short task agent compared with a long-running agent
| Short task agent | Long-running agent | |
|---|---|---|
| Duration | Seconds to minutes | Hours to days |
| Where state lives | In the context window | In files, commits, a session log or a database |
| Context strategy | Fits in one window | Compaction, context resets or context editing |
| Failure that matters | A wrong answer | Drift, early stops or acting on steps that never happened |
| Human role | Review the result | Review the plan, the milestones and the result |
Common questions
How long can an AI agent run?
Published examples range from hours to days. OpenAI describes a Codex run of about 25 hours, and Google's Agent Runtime keeps long-running agent state for up to seven days.
What is the difference between compaction and a context reset?
Compaction summarises the history in place so the same session continues. A context reset starts a fresh session from a structured handoff file, which gives a clean slate at the cost of more orchestration.
How do long-running agents avoid claiming they are done too early?
By defining done before work starts, as a checklist where every item begins as failing, and by requiring tests or an evaluator to pass before an item flips.
Related
Compaction
Summarise the old turns, keep working: the standard move for long agent runs.
Harness engineering
Designing the environment an agent works in, so its output can be checked and shipped.
Agent memory
Session state for the task at hand, plus stored knowledge the agent recalls later.
Context rot
Why agents get worse the longer they run, and what keeps context clean.
AI agent development
Agents that do real work for users, with the evals, traces and guardrails to keep them in production.
Execution derailment
When an agent loop loses the thread as its context fills up.
Sources
- Anthropic, Effective harnesses for long-running agents (2025-11-26)
- Anthropic, Harness design for long-running application development (2026-03-24)
- Anthropic, Scaling Managed Agents: decoupling the brain from the hands (2026-04-08)
- OpenAI, Run long horizon tasks with Codex
- Google Developers Blog, Build long-running AI agents that pause, resume and never lose context with ADK (2026-05-12)
- Google Cloud, Five must-have guides to move agents into production (2026-05-06)
Running agents that have to hold up?
Describe the agent, the systems it touches and what it must never get wrong. The first call is with a lab engineer, who will say plainly whether it is ready for production, and whether Motiontic is the right team.