Long-Running AI Agents Need Durable State Machines, Not More Function Calls

A comparison of managed public-cloud workflows and OpenStack TaskFlow for AI-agent jobs that wait, retry, request approval, and recover from failure.

When an AI agent performs real work, the job rarely ends with one model call. The agent may read a ticket, wait for approval, change a cloud resource, and verify the result while its process is restarted underneath it. The important question is not whether the model can choose the next tool well. It is whether the job can resume safely from the same state after an interruption.

An AI-agent workflow connecting public-cloud and OpenStack control planes through checkpoints, retries, and recovery paths, AI-generated image

A model call has no durability by itself

A typical agent loop sends the current conversation and tool results to a model, executes the next action, and feeds the result back to the model. If that loop exists only in memory, a process crash erases the execution point. If a network timeout causes the tool call to be sent again, the system may create the same server twice or process an external side effect twice.

A long-running job should persist at least these fields:

  • the calling principal, goal, and policy version
  • model and tool versions, current state, and last trusted input
  • idempotency keys and results for requests sent to external systems
  • human approvals, holds, rejections, and their reasons
  • retry count, next-attempt time, compensation action, or manual recovery path

This is more than a log. It is execution state that lets the agent determine what has already happened and which facts can be trusted before it reasons about what to do next. The model may propose a plan, but the execution engine must own valid state transitions and resume points.

Public clouds package waiting and recovery as products

Public-cloud orchestration services provide much of the foundation for long-running agents even when they are not marketed only as agent features. AWS Step Functions’ workflow-type documentation describes Standard Workflows as suitable for long-running, durable, and auditable workflows of up to one year. It distinguishes their default exactly-once execution model from Express Workflows, which favor high throughput and at-least-once execution. This separates an agent job from the lifetime of a model session. It does not make an external API side effect exactly-once automatically, so the task still needs idempotency and result reconciliation.

The Azure Durable Functions overview describes stateful workflows built from orchestrator, activity, and entity functions. The runtime manages state, checkpoints, retries, and recovery. If an agent must wait days for a human approval or for an asynchronous external operation, the orchestration can preserve state instead of holding a server open.

The Google Cloud Workflows overview describes Workflows as a fully managed, serverless orchestration platform whose executions can wait, retry, or poll for up to a year. It also identifies Workflows as a regional service. That is convenient when building an agent product quickly, but it leaves a separate design question: which region stores the execution state, and which state store, credentials, and tools move with it during regional recovery?

The common benefit is a productized control plane for state, waiting, retries, audit history, and resumption. A platform team can separate an agent’s plan from its actual side effects without building all of those mechanics first. The trade is dependence on a provider’s workflow language, event model, identity system, regional boundaries, and billing units. Managed does not mean that failure disappears. It means that part of the control plane for recording and resuming failure is purchased.

OpenStack requires assembling the execution boundary

In the OpenStack ecosystem, the TaskFlow documentation is a useful point of comparison. TaskFlow is a Python library that makes task execution easier. Its engine documentation separates the structure of a flow from the way it is executed, and describes how an engine tracks current state so a flow can resume. It can combine task execution and reversion, parallel flows, and storage, which provides useful building blocks for durable execution.

TaskFlow is not a fully managed public control plane that also owns infrastructure operations, billing, regional recovery, and service integrations. An OpenStack platform team must combine a workflow engine or another orchestration service with a message queue, state store, Keystone credentials, and audit trail. If a Nova instance is created and a Neutron network operation fails halfway through, the organization must define how an already-created port is cleaned up, what happens when cleanup also fails, and when the workflow becomes a manual-recovery case.

That responsibility is also control. The team can decide which database and physical boundary hold execution state, which projects and host sets receive work, and where external connectivity is blocked. The goal is not to reproduce a public-cloud orchestrator as a less finished product. It is to choose the durability scope and operating cost that the organization can govern.

The trade between the two execution control planes

The difference between public cloud and OpenStack appears less in API names than in where the control plane lives. A long-running AI-agent job should be compared across these dimensions.

DimensionManaged public-cloud workflowOpenStack-based private platform
Control-plane locationThe provider operates workflow state, execution history, events, and retries as a serviceThe platform team assembles the workflow engine, state store, queue, and audit boundary
Virtualization, network, and storageUses regional, availability-zone, managed-storage, and service-integration boundariesOperates Nova, Neutron, Cinder, physical paths, and storage backends directly
MultitenancyDepends on accounts, projects, roles, execution limits, and provider isolationDefines project, role, queue, state-store, and host-set boundaries directly
Accelerator choiceSelects from the GPU, TPU, and accelerator catalog exposed by the runtime and model serviceConnects owned accelerators to drivers, passthrough, and scheduling policies
Data sovereigntyCombines region, network, log-retention, and managed-service contract controlsProves the physical location and external path of state, prompts, tool results, and audit logs
Cost controlSees execution, transition, waiting, model-call, and network costs on provider billsCalculates hardware, reserve capacity, power, storage, and operating staff alongside state costs
PortabilityGains fast integration but accumulates dependency on workflow syntax, events, identity, and toolsControls the infrastructure boundary but needs expertise to operate the platform itself
Ecosystem and skillsUses managed connectors and observability while following provider changesKeeps OpenStack, workflow, network, security, and model-operations expertise in-house
Failure recoveryUses productized paths across zones, regions, and managed state storesTrains recovery for the engine, queue, state store, Keystone, models, and infrastructure dependencies together

It is too quick to conclude that public cloud is right for agents and OpenStack is not. Managed workflows are attractive when a team must connect external services and models quickly while minimizing platform operations. An OpenStack-based platform gives more choice when the team must keep sensitive data, internal systems, fixed network boundaries, and a specific accelerator mix under long-term control. When the two are combined, record which control plane owns the workflow state and every tool call.

Design the agent job as a state machine

The safer split is to let the model propose transitions while the execution engine validates them, instead of asking the model to own the entire job.

First, make business stages explicit. Use human-readable states such as requested, planned, awaiting_approval, executing, verifying, completed, and needs_manual_recovery. Do not infer the current state from an unstructured conversation alone.

Second, put an idempotency key and preconditions before every external side effect. For an instance-creation request, persist the job ID, target project, and desired state. After a timeout, query the existing operation before sending the request again. A promise from the model to “call it only once” cannot control a network retry.

Third, distinguish retries from compensation. A transient 503 or connection failure can use exponential backoff, but an operation with an unknown result must not be blindly repeated. If a network port was created before server creation failed, try a compensating cleanup action, but record cleanup failure as manual recovery rather than pretending that the workflow completed.

Fourth, treat waiting as a cost and security concern. Do not hold a GPU or a long-lived operator token while waiting for a human approval or callback. Revalidate expired credentials and changed policies when the job resumes. If the wait exceeds the budget or SLA, stop automatically or transfer ownership to an operator.

Fifth, pin model and policy versions in the execution state. A job resumed days later by a newer model may propose a different tool call for the same input. Separate states that may be replanned from states that may only execute an approved plan, and test whether a model change alters the meaning of existing work.

Measure recoverability, not only completion

Completion rate alone makes a fast system look better than a recoverable one. Long-running agents should also record:

  • the percentage of jobs that resume automatically after a process restart
  • duplicate tool calls and duplicate side effects
  • time waiting for human approval and expired approvals
  • retries that succeeded versus jobs that required compensation
  • recovery time when the state store, queue, or workflow engine fails
  • compute, storage, and model-call cost held while an agent waits
  • changes in transition errors and manual intervention after model, tool, or policy updates

Recovery exercises should go beyond restarting a model server. Test an engine that is alive while its state store is stale, duplicate queue delivery, credentials that expire after approval, and a successful Neutron operation whose response never reaches the agent. In public cloud, validate recovery across regions and service boundaries. In OpenStack, recover Keystone, the message queue, databases, network paths, and storage backends as one operating procedure.

Agent autonomy is better measured by the range of work that can continue safely through interruption, delay, approval, partial success, and external failure while preserving its goal and authorization boundary. Public clouds let teams buy this execution control plane quickly. OpenStack lets them govern the resource and data boundary where that control plane runs. Either way, the agent’s first capability should be a recoverable record of state, not merely an impressive answer.

The following official sources were checked for this article. AWS Step Functions workflow types was used on November 30, 2026 to verify the Standard and Express execution guarantees, long-running scope, and use cases. The Azure Durable Functions overview was used to verify runtime-managed state, checkpoints, retries, and recovery. The Google Cloud Workflows overview was used to verify managed orchestration, up-to-one-year waiting, and regional service behavior. The OpenStack TaskFlow documentation and engine documentation were used to verify the execution-engine, state-tracking, resumption, and reversion model.