Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 10 min read

An Agent That Runs All Weekend Can Also Fail All Weekend: Architecting 24/7 AI Agents

Almost every agent in production today has the same shape. A human types something. The agent plans, calls a few tools, and returns. Then it forgets the whole thing until somebody types again. That design hides a lot of

Almost every agent in production today has the same shape. A human types something. The agent plans, calls a few tools, and returns. Then it forgets the whole thing until somebody types again.

That design hides a lot of problems. The session ends before costs get big. A human reads every output. If the agent goes wrong, it stops when the tab closes.

Take the human out of the loop and all of that goes away.

At Microsoft Ignite this month, the announcement was Autopilot in Microsoft Copilot: persistent agents with memory, identity, and tools that keep working across days. An example of an always-on is an account-management agent that watches your inbox and customer conversations, follows up on action items, and flags risks without anyone restarting it each morning.

That is a different kind of software. A chat agent is a request handler. An always-on agent is closer to a daemon, and daemons need things request handlers never did: a scheduler, durable state, a stable identity, a spending limit, a way to pause for approval, and someone watching what it does at 3 a.m.

This post covers that architecture and the parts you need to use.

From request/response to daemon

Here's the difference in one picture:

REQUEST/RESPONSE AGENT                 ALWAYS-ON AGENT
──────────────────────                 ───────────────
 human prompt                           events ─┐  schedules ─┐  other agents ─┐
     β”‚                                          β–Ό             β–Ό                β–Ό
     β–Ό                                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 plan β†’ tools β†’ answer                     β”‚          durable work loop           β”‚
     β”‚                                     β”‚  wake β†’ load state β†’ decide β†’ act    β”‚
     β–Ό                                     β”‚     β†’ checkpoint β†’ sleep/wait        β”‚
 session ends, state gone                  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                   β”‚              β”‚
 human reviews 100% of output             approval gate      telemetry + spend
                                          (only some actions)   (always)

Three things change.

Lifetime. A chat turn lasts seconds. A follow-up on an action item can take two weeks. The agent's "context" can't be a context window anymore. It has to be state stored somewhere outside the model.

Who starts it. Nobody prompts the agent. Webhooks, CRON schedules, database changes, and other agents wake it up. The trigger layer is now part of the product.

Oversight. Humans stop reading every output. They see exceptions and approvals. So the system has to know which actions count as exceptions, and the model can't be the one deciding that.

The seven parts of an always-on agent

Below are described generically as they apply on any stack:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 7. SECURITY OPERATIONS   red / blue / green team agents, continuous  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 6. GOVERNANCE & REGISTRY owner, scopes, lifecycle for every agent    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 5. IMPROVEMENT LOOP      traces β†’ evals β†’ tested change β†’ release    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 4. SPEND CONTROL         budgets per agent, cost per outcome         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 3. CONTEXT               business knowledge + live operational data  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 2. MANAGED RUNTIME       hosting, identity, durable state, approvals β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1. TRIGGERS              events, schedules, agent-to-agent messages  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Layer What the Ignite issue mapped to it Question it answers
Triggers + persistence Copilot Autopilot What wakes the agent, and what does it remember?
Managed runtime Copilot Managed Runtime Where does it run, and as whom?
Context Microsoft IQ, Fabric HorizonDB Does it understand this business, right now?
Spend control Agent 365 Cost Management, Foundry FinOps What is each outcome costing?
Improvement loop Foundry continuous improvement Is it getting better or drifting?
Governance Microsoft Agent 365 Who owns it, and what can it touch?
Security ops Microsoft Perception Who is attacking it, and who fixes the gap?

You can build each of these yourself or buy them. What you can't do is skip one. Every missing layer shows up as a specific kind of incident. The rest of the post goes through the layers where those incidents usually come from.

1. Triggers: the agent's front door is no longer a text box

Once nobody prompts the agent, the events that wake it become its input, and its attack surface. Treat each trigger like an API endpoint: it has a schema, it gets validated and deduplicated, and it is rate-limited.

# agent.triggers.yaml β€” declarative, reviewable, versioned
agent: account-followup
triggers:
  - type: email.received
    filter: "to:accounts@ AND from_domain IN customer_domains"
    dedupe_key: "message_id"
    max_rate: 200/hour
  - type: schedule
    cron: "0 7 * * 1-5"         # weekday morning sweep of open action items
  - type: crm.opportunity.updated
    filter: "stage_changed OR close_date_moved"
  - type: agent.message
    from: [contract-review-agent]

Two rules that save you later:

Make every trigger idempotent. Webhooks get retried and schedulers fire twice. If the same email wakes the agent twice, it should not send two follow-ups. Store a dedupe key with every action the agent takes.

Give the agent a quiet mode. An always-on agent needs a state where it watches but doesn't act. That's how you deploy it safely and how you stop it during an incident without losing its queue.

2. Durable state: the context window is not memory

A follow-up that spans ten days can't depend on a conversation being kept alive. The pattern that works is the one workflow engines have used for years: checkpoint after every step, and rebuild the model's context from the checkpoint on every wake-up.

# Simplified always-on work loop. The model is stateless; the run is not.
def handle_wake(event):
    run = store.load_or_create(run_key(event))        # durable state
    if store.already_processed(event.dedupe_key):
        return                                         # idempotency

    while not run.done:
        ctx = build_context(run, event)                # rebuilt every wake
        step = model.decide(ctx, tools=run.allowed_tools)

        if budget.would_exceed(run.agent_id, step.estimated_cost):
            run.status = "paused_budget"; break

        if policy.requires_approval(step.action):      # outside the model
            approvals.request(run.id, step)            # human/async
            run.status = "awaiting_approval"; break

        result = tools.execute(step.action, idempotency_key=step.id)
        run.append(step, result)
        store.checkpoint(run)                          # crash-safe

        if step.wait_until:                            # e.g. "check reply in 3 days"
            scheduler.wake_at(run.id, step.wait_until); break

    store.mark_processed(event.dedupe_key)

Notice what isn't in the loop: a transcript that keeps growing. The run stores structured facts (what it was asked to do, what's been done, what it's waiting for, what it decided and why) and build_context turns them into a small prompt each time. That keeps token costs flat over a ten-day run, and it means a crash halfway through only loses one step.

It also makes the agent debuggable. When someone asks why it emailed the customer on Thursday, you have a checkpointed decision to look at, not a 400k-token transcript you'd have to rebuild.

3. Identity and approvals: autonomy is a permission, not a model property

Once you have hundreds of agents, you need to know who owns each one, which tools it can use, and how its identity and access are managed. An example is a procurement agent that can read supplier records and start approvals. Its access has to change as its job changes.

In practice, every always-on agent gets three things that a chat assistant usually borrows from whoever is using it:

agent identity      β†’ its own principal, not a human's delegated token
scoped grants       β†’ read:crm.accounts, draft:email, send:email(limit=20/day)
action tiers        β†’ which actions run free, which queue for a human

Action tiers are the core of it. A workable default:

Tier Examples Behavior
Observe read inbox, query CRM, search docs Runs freely, logged
Reversible create draft, add CRM note, set reminder Runs freely, summarized daily
External send email, post to customer channel Runs within quota; first N per new recipient need approval
Irreversible / financial sign, pay, delete, change access Always requires human approval

The model can propose an action in any tier. Whether it runs is decided by a policy service outside the model, which the model can't talk its way past. That keeps you safe when a hostile email in the inbox tells the agent to forward everything to an outside address. In a request/response agent, a human would probably have spotted that. In an always-on agent, nobody is reading.

4. Spend control: a loop with no budget is a bill with no ceiling

Agents running 24/7 sound great, but every model call, tool call, retry, and long-running workflow adds cost.

A chat agent's cost is limited by how patient the user is. An always-on agent has no such limit. A retry loop on a broken tool will run all weekend.

Three controls, in order of importance:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ HARD CAPS      per run, per agent per day, per tenant        β”‚
β”‚                β†’ enforced in the loop, before the call       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ ATTRIBUTION    every call tagged {agent, run, workflow,      β”‚
β”‚                model, outcome}                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ UNIT METRIC    cost per successful outcome, incl. retries    β”‚
β”‚                and human review time                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

cost per successful business outcome is an important metric, not tokens consumed. Knowing exactly how much your RFP agent costs per completed proposal, and whether that number falls as quality improves. For an always-on agent this is the most important dashboard you'll have. If cost per completed follow-up goes up while volume stays flat, something is looping.

5. Context: smart models don't know your business

A frontier model reasons well, but it doesn't automatically know your customers, internal policies, business metrics, or past decisions. The supply-chain example layers four kinds of context:

 External signal    ── supplier shutdown in breaking news
 Business data      ── inventory, supplier dependencies, revenue impact
 Enterprise docs    ── supplier contracts, procurement policy
 People & history   ── related discussions, prior decisions, who owns this
          β”‚
          β–Ό
 recommend alternate suppliers β†’ assess risk β†’ coordinate next steps

For an always-on agent there's one more requirement: freshness. A chat agent reads context at prompt time. An agent that wakes up three days into a run is working from three-day-old assumptions unless it re-reads live operational data. That's why agents need to see what is happening now (current stock, a live claim) next to analytical history (demand forecasts, past claim patterns) before deciding what to do next.

The rule: on every wake-up, refresh anything the next action depends on. Never act on a cached fact you could cheaply re-check.

6. Continuous improvement: deployment is the starting line

With always-on agents this matters even more, because nobody is reading every output and failures stay hidden until they pile up.

production trace ──► reviewer flags miss ──► new eval case
       β–²                                         β”‚
       β”‚                                         β–Ό
  release gate ◄── quality + cost targets ◄── candidate change
                                              (prompt / skill / model)

The example: an RFP agent keeps missing a contractual requirement. A reviewer flags it, the flag becomes an evaluation case, and the next version is tested against it before release. For a continuous agent, set up the flagging path before launch. Use a thumbs-down on the daily summary, a "wrong action" button on approval requests, and a weekly sample of autonomous actions for spot review.

7. Security operations: attackers don't keep office hours either

Whatever tooling you use: if agents run business processes around the clock, the processes protecting them have to run around the clock too.

For your own agents that means the triggers, tool grants, and approval policies above should be tested the way an attacker would test them, on a schedule, not once before launch. Seed the inbox with injection attempts. Make a tool fail on purpose and check whether the budget cap catches the retry storm. Try to get a Tier 2 action to run without approval.

A rollout path that doesn't end in an incident review

Week 0   Pick one workflow someone restarts by hand every day
Week 1   Shadow mode: agent observes + drafts, humans act; log cost per run
Week 2   Tier 0–1 autonomy: reads and reversible actions only
Week 3   Tier 2 with per-recipient approvals + daily spend cap
Week 4+  Widen quotas only where eval pass rate and cost/outcome hold

Every step needs a number before you move on: drafts accepted unedited, approvals rejected, cost per completed outcome, incidents. If you can't measure a step, don't move past it.

The bigger picture: the model is one part of a larger system

The model matters, but so do the tools, context, runtime, data, and governance around it. GitHub's Copilot Fusion showed that idea at the inference layer, routing each coding request to a single model, a model plus reviewer, or several models critiquing each other.

Always-on agents push that argument as far as it goes. When nobody is watching each turn, how smart the model is matters less than how well the system around it is built. A slightly weaker model with idempotent triggers, checkpointed state, tiered permissions, and hard budget caps will beat a frontier model running in an unbounded while True: loop.

Key Takeaways

  • Always-on agents are daemons, not chatbots. They need triggers, durable state, a scheduler, and a way to stop safely. None of that comes from the model.
  • Rebuild context from checkpoints on every wake-up. Don't keep a transcript alive. That keeps costs flat over multi-day runs, makes crashes cheap to recover from, and makes decisions auditable.
  • Autonomy is a permission tier enforced outside the model. Observe and reversible actions run freely. External actions run within quotas. Irreversible and financial actions always wait for a human.
  • Budget caps go in the loop, not on a monthly invoice. Track cost per successful outcome, including retries and review, as the main health metric.
  • Plan the improvement and security loops before launch. Without people reading every turn, flagged misses and scheduled adversarial tests are how you find out the agent has drifted.

Your turn

When nobody reads every output, which action would you never let an agent take autonomously, even with a perfect eval score? And is that line drawn by the risk of the action, or by how much your organization trusts AI right now?

Tell me in the comments. I suspect the answers vary much more by industry than by model.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.