Build an Agent that Never Sleeps
Build background agents that can observe, act, recover from interruptions, and ask for help without losing track of the work. Stay in control as you run reliable agent workflows behind the scenes.
What is a background agent?
A background agent is a process that runs autonomously to enforce a goal or maintain a desired state, without requiring you to prompt it each time or wait for it to complete.
Unlike a chat agent where you give it a task and wait synchronously for a response, a background agent operates asynchronously in the background. You give it a goal—like "monitor my email inbox" or "keep this service healthy"—and it continuously works toward that goal, responding to events and making decisions on its own.
Key characteristics:
- Goal-oriented, not task-oriented: Instead of a single prompt, you define a vision of what you want the world or system to look like, and the agent enforces that vision.
- Event-driven: It can be triggered by external events (like a new email arriving) rather than waiting for your input.
- More durable and resilient: If something fails—an API call times out, a tool breaks—a background agent keeps working toward the goal, pausing and resuming as needed, rather than giving up like a synchronous chat agent would.
- Fire and forget: You set it up and walk away. It doesn't need you to verify each step or tell it when to act.
The real productivity unlock is that you're not the bottleneck anymore. It's like having a team member who knows their job, knows when to do it, and doesn't need constant direction—they just keep things in harmony with the state you defined.
Explain observe-decide-act loop?
An observe-decide-act loop is the core architecture for how a background agent processes work. Here's how it flows:
- Observe: When an event triggers the agent, it first observes the current state of the world or system you've given it. It gathers information about what's happening right now.
- Decide: Based on that observed state, the agent reasons about what action to take next to move toward its goal.
- Act: The agent executes that action, then loops back to observe again.
It's a continuous cycle—observe the state, decide what to do, do it, then repeat. This is similar to how most agent tool loops work today, but there are some key differences in how you build it for background agents:
- No tool calling: Unlike traditional agent SDKs, this harness doesn't use model-level tool calling. The agent still picks actions, but through a different mechanism.
- Can wait and suspend: Because it's running in the background with proper architecture, the agent can pause and wait for something (like user input or an external event) without consuming compute, then resume later. A chat agent can't really do that—it either completes or times out. But a background agent can suspend gracefully, like a person waiting for a response, and pick up where it left off days later if needed.
The loop keeps running as long as the agent hasn't reached its goal or hit a stopping condition, continuously responding to new events and adjusting its actions based on the current state.
What is a background agent and how does it differ from a conversational agent like ChatGPT or Claude?
A background agent is an intelligence system that can watch events, run on a schedule, or handle tasks without prompting. Unlike conversational or chat-based agents that require direct interaction, background agents can be given a goal and continue to work until they reach that goal. They can operate autonomously and reach out for help or approval when needed, without requiring constant supervision.
What 3 main components combine to create a background agent system?
A background agent system is a combination of: 1. a harness (to control and validate agent actions), 2. infrastructure (to run the agent continuously), and 3. traditional agent capabilities (AI decision-making). These components work together to allow an agent to run indefinitely, heal itself, and accomplish tasks autonomously.
What is the purpose of a harness in a background agent system?
The harness protects the system by setting valiation checks and restrictions on what the agent can do. It can prevent the agent from performing destructive actions autonomously and require human approval for certain operations. It also enables deterministic behavior, such as ensuring the agent must reach out for help when specific conditions are met.
What are the two main conditions under which a background agent reaches out to humans for help?
A background agent reaches out to humans in two main situations: 1. When it needs context or is uncertain about something and requires an answer to a question, and 2. When it wants to perform an action that requires human approval, where the harness locks down that action behind explicit human authorization.
In a system monitoring use case, what types of information does a background agent observe when investigation a service issue?
When investigating a service issue, a background agent observes the alert that triggered the investigation, examines the current state of the service at the time the event occurred, reviews logs and events associated with the service, and continuously monitors for new events (such as health recovery notifications) that may affect the investigation.
What is a key characteristic of background agents compared to conversational agents?
They run on schedules or watch events without requiring prompts
In a human-in-the-loop agent system, what belongs in an operator inbox?
Questions needing human context and approval requests that gate restricted actions
What is the purpose of requiring human approval for certain agent actions in the harness?
To prevent the agent from performing potentially destructive operations without oversight
What is a key difference between chat agents and background agents in terms of execution model?
Chat agents operate synchronously — they require a prompt and wait for a response in a back-and-forth process. Background agents are asynchronous and fire-and-forget; they can operate independently without requiring constant prompting and can continue working toward a goal without user interaction.
How does a background agent differ from a chat agent when handling failures or errors during task execution?
A chat agent will typically try alternative approaches and eventually return a failure message if it cannot complete a task. A background agent is more resilient and durable — it will continue attempting to achieve its goal over time, can pause and resume when needed, and persists through failures similar to how a person would keep working to solve a problem.
What is the observe-decide-act loop in agent architecture?
The observe-decide-act loop is an agent thinking framework where: (1) the agent observes the current state of its environment, (2) decides what action to take next based on that observation, and (3) executes that action, then repeats the loop. This continues until the agent achieves its goal or encounters a condition that requires it to wait or stop.
Why should deterministic approval requirements be handled by the harness rather than delegated to the LLM in a background agent system?
LLMs can hallucinate, so if you rely on an LLM to determine whether it needs approval for an action, it might incorrectly decide it doesn't need permission when it should. Deterministic logic like approval requirements should be enforced by the harness to ensure consistent, reliable behavior and maintain proper authority boundaries.
What capability distinguishes background agents from traditional coding agents when dealing with long wait times for user input?
Background agents can suspend their state and wait indefinitely for input (like waiting days for a user response) without keeping compute resources or connections open. Traditional chat or coding agents typically cannot maintain state across extended periods — the process ends, connections close, or state becomes stale if the user doesn't respond quickly.
In the observe-decide-act-loop architecture, what distinguishes it from traditional tool-calling approaches?
The agent picks actions without using tool calling at the model level
Why is it problematic to rely on an LLM to determine whether it needs approval before taking an action?
Since LLMs can hallucinate, they might also hallucinate whether approval is needed
What advantage do background agents have over chat agents when handling long-running tasks that encounter failures?
They are more resilient and can pause, wait, and resume work toward the goal
Can you use the Claude API instead of OpenAI when using the AI SDK?
Yes, the AI SDK is model-agnostic and uses the same code regardless of the model provider. You only need to change the model name in the configuration, and the rest of the code remains the same.
What is Inngest used for in a multi-service Node.js application?
Inngest handles event-driven communication and durable execution between services, such as between the checkout service and the agent API.
Why might you need to modify code when switching from OpenAI API to Claude API when using the AI SDK?
While the AI SDK uses the same code structure regardless of which model you're using, you need to change the model name configuration where it's specified in your code. The SDK itself is model-agnostic, but the specific model identifier must be updated to reference Claude instead of OpenAI.
In an agent-based monitoring system, what are the three stages of the core loop that an agent performs?
The three stages are: observe the current world (the state of the service), decide on the next action based on the current state, goal, and history of actions already taken, and act by executing the selected action (which is validated by the harness).
What is the difference between model-directed actions and harness-delegated actions in an agent system?
Model-directed actions are decisions the agent makes about which tools to use based on prompts. Harness-delegated actions are enforced at the code level by the harness itself, regardless of what the agent decides. For example, the harness can automatically provide state updates to the agent or restrict certain operations like rollbacks, even if the agent recommends them.
In an agent monitoring system, what constitutes the 'world' that the agent needs to understand?
For an agent monitoring a service, the 'world' is the complete state of that service, including whether it's healthy, HTTP response codes it's returning, recent alerts, and any other information related to the service's current operational status.
Why would an agent harness automatically reject certain agent actions like rollbacks, even if the agent recommends them?
The harness enforces policies set by the system designers to prevent potentially costly or dangerous operations. If rollbacks aren't allowed, the harness will intercept that recommendation and route it to a human for approval instead. This prevents the need to rely on prompting alone to control the agent's behavior, which can be unreliable.
What are the three core steps in an autonomous agent's control loop for observing and responding to system state?
The three core steps are: (1) Observe the current world state (automatically fed to the agent on every loop), (2) Decide what action to take next based on the current state, the agent's goal, and the history of actions already taken, and (3) Act by executing the selected action after the harness validates it. This observe-decide-act loop allows the agent to continuously monitor and respond to changes in the system it manages.
What are the three main stages of the agent loop in an observability harness?
Observe, predict, and act
In the agent harness design, what determines whether certain actions like rollbacks can be executed?
The harness validates permissions at the code level, not the agent
What is the distinction between 'world state' and 'run state' in the agent harness?
World state is the current condition of the service being monitored, while run state tracks the investigation progress and actions taken
Related reading
Measuring Platform TCO the CFO Will Actually Believe
A practical model for calculating total cost of ownership of a digital experience platform — and defending the number in a budget review.
ReadVendor Economics for Web Platform Leaders
How to structure agency and SI relationships so they scale with you — not against you — as the platform matures.
Read