The Five Core Components of an Always-On AI Agent Architecture

    This article breaks down the architecture of always-on AI agents, which move beyond passive request-and-response systems to reliably execute tasks without human intervention. It explains the two fundamental units of run and session, then examines five core components: an event inbox that unifies heterogeneous trigger sources, a persistent scheduler for follow-ups and recurring jobs, layered memory with on-demand retrieval, a least-privilege permission model with explicit approval, and an outbox for unified delivery and failure isolation. A deployment checklist and closing guidance help readers turn a demo agent into a production system where the real complexity lies in state management and scheduling rather than model capability.

    Introduction: From One-Shot Replies to Always-On Execution

    Most agent systems still operate in a passive response mode: the user sends a message, the model reasons once, a result is returned, and the flow ends. These systems are simple to build, but they quickly hit limits in real business scenarios. They cannot advance a task on their own while nobody is watching, they cannot recover their state after an interruption, and they cannot handle concurrent requests arriving from multiple channels.

    Always-on agents are designed to solve exactly these problems. The essence is not “keeping the model reasoning forever,” but repeatedly triggering a very short execution loop and chaining it together reliably. Understanding this is the key step in moving from a demo to a production-grade system.

    1. Two Basic Units: run and session

    To understand an always-on architecture, start by separating two concepts that are easy to confuse.

    • run (a single execution): receives an event, completes the corresponding work, persists the process and the result, and then ends. A run is a one-off execution unit with clear boundaries.
    • session (conversation context): the record of a complete interaction, containing all messages, tool calls, and intermediate artifacts. A run executes on top of a session.

    The relationship can be summarized as: the run is the “action,” and the session is the “memory carrier.” When a run finishes, the agent goes dormant and consumes no compute. When the next event arrives, the system decides whether to reuse an existing session and continue, or to create a new one.

    “Always on” does not mean holding resources continuously. It means running the short loop of “sleep — wake up — execute — sleep again” reliably billions of times. The engineering complexity therefore shifts from “model capability” to “scheduling and state management.”

    2. The Event Inbox: One Entry Point for Every Trigger

    An ordinary agent has a single trigger source: the user message. An always-on agent has highly heterogeneous trigger sources, commonly including external callbacks, scheduled jobs, notifications that a background job has finished, and results returned by other agents.

    If every source calls the agent directly, two serious problems appear. First, concurrency conflicts: two events arriving at the same time start two runs that compete for the same context. Second, missing reliability: if the process crashes, the events are lost with it.

    The answer is to insert an inbox between the trigger sources and the execution layer. Every source only writes; a background worker only reads. In practice this is usually a persistent table with a write endpoint and a polling or wake-up consumer.

    Four key practices:

    1. The write side must return fast. Many external callback mechanisms treat a slow response as a failure and redeliver, which creates an event storm. Time-consuming validation, such as a safety check on the input, should happen inside the run.
    2. The inbox is the single source of truth. After a worker wakes up, it first fetches the latest list of events. Even if it crashes midway, a newly started worker can pick the events up again and continue.
    3. Only one active worker per inbox at any given moment. Use a distributed lock or a lease mechanism to guarantee mutual exclusion, avoiding duplicate execution and conflicting state overwrites.
    4. Merge pending events. If a user sends three messages in a row, they should be merged into a single run and answered once, which saves inference cost and prevents the context from being fragmented.

    Illustrative pseudocode:

    1. def handler(event):
    2. inbox.append(event) # Persist only, then return immediately
    3. return "accepted"
    4. def worker_loop():
    5. while True:
    6. batch = inbox.fetch_unprocessed(limit=50)
    7. if not batch:
    8. sleep(1); continue
    9. with lease("inbox", owner=INSTANCE_ID):
    10. run(merge(batch)) # Single execution after merging

    3. The Scheduler: Let the Agent Remember Its Own Work

    The inbox handles “something outside needs you.” The scheduler handles “you have something of your own to do.” It likewise cannot rely on the model to “remember,” and must be externalized as persistent scheduling data.

    There are two types of timers:

    • follow-up (one-off): a deadline the agent sets for itself, for example checking in with a user three days later to see whether the proposal was adopted. Once it fires and is marked complete, it ends.
    • schedule (recurring): a loop at a fixed cadence, for example generating a summary report every morning. After each execution, the next due time must be pushed forward before waiting again.

    The engineering point is to keep the timer table separate from the inbox table: when a timer is due, the scheduler posts an event into the inbox, and the same worker consumes it. This keeps a single entry point for all execution paths, so permission checks, auditing, and retry logic do not have to be reimplemented. You also need to handle idempotency (a redelivered event must not execute twice), time zones and daylight saving time, and staggering (avoiding a large batch of jobs all firing in the same second).

    4. Memory: Layered Storage and Retrieval on Demand

    Running continuously means the context grows without bound. Putting everything into the session is neither economical nor accurate. The reasonable approach is to layer it:

    • Short-term memory: the messages and tool calls of the current session, archived when the run ends.
    • Working memory: intermediate conclusions, todos, and confirmed constraints that span runs but belong to the same task.
    • Long-term memory: preferences, facts, and environment information that span tasks, usually requiring retrieval rather than loading everything.

    The implementation principle is “write structured, read by retrieval”: structured fields support exact filtering, vector retrieval supports semantic recall, and a hybrid ranking of the two is more stable. Forgetting and correction mechanisms are also mandatory. Expired information must be able to become invalid, and wrong conclusions must be explicitly overwritten; otherwise memory keeps contaminating later decisions.

    5. Permissions: Put Authorization Back in Human Hands

    An always-on agent takes actions while unattended, so the permission model becomes the core of the security boundary. The recommended approach is least privilege plus explicit approval:

    • Authorize per tool, distinguishing three levels: read-only, reversible writes, and irreversible operations.
    • Irreversible actions, or those involving money or sending things externally, enter a pending-approval queue and are released only after a human confirms.
    • Approval requests themselves must be persisted, and a request left unhandled past its timeout is rejected by default.
    • All authorization and execution records go into an audit log for traceability.

    In general practice on cloud platforms such as Baidu AI Cloud, these capabilities are typically assembled from foundational categories such as identity and access management, key management, logging services, and monitoring and alerting, rather than depending on a single component.

    6. The Outbox: One Exit and Failure Isolation

    Symmetric to the inbox, all outbound output should go through an outbox: a run only writes “pending to send,” and a separate dispatcher handles the actual sending, retries, and rate limiting. There are three benefits: instability in an external channel cannot drag down execution; sending can be made idempotent and deduplicated; and failures can be retried in tiers, with those that keep failing moving to a dead-letter queue for manual handling.

    7. Deployment Checklist

    1. Do all events enter through the single inbox entry point?
    2. Is there a global mutual-exclusion worker lease?
    3. Is the scheduler decoupled from the inbox, with idempotency and staggering support?
    4. Is memory layered, retrievable, and able to expire?
    5. Do high-risk actions have approval and auditing?
    6. Is all output delivered and retried through the outbox?
    7. Can the whole chain self-heal after a crash?

    Conclusion

    The hard part of an always-on agent is not the model, but state and scheduling. Draw the boundary between run and session clearly, and build the five parts — triggering, scheduling, memory, permissions, and output — into reliable infrastructure. Only then can an agent truly go from “able to chat” to “able to keep getting things done.”