85 agentic tools audited for security incidents · Talk to the lab →
MotionticBook a call
Glossary

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

A short task agent compared with a long-running agent
Short task agentLong-running agent
DurationSeconds to minutesHours to days
Where state livesIn the context windowIn files, commits, a session log or a database
Context strategyFits in one windowCompaction, context resets or context editing
Failure that mattersA wrong answerDrift, early stops or acting on steps that never happened
Human roleReview the resultReview 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.

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.