AI Agent Architecture: From Conversation to Action in a Local Runtime
This article breaks down the architecture behind the new wave of local, executable AI agents — tools that go beyond returning text to actually changing state on your machine. It covers why these tools run as long-lived local daemons rather than stateless web apps, and walks through each layer: channel adapters that normalize messages from IM, email, and the CLI; a gateway and scheduler that defaults to per-session serial execution with explicit parallelism; a tool execution layer with declarative registration, pre-execution parameter validation, and output trimming; tiered persistent memory; and sandboxed self-extension of skills. It also includes a practical build checklist, the principle that agent autonomy should be inversely proportional to the reversibility of an operation, and an honest account of the risks: error amplification, unpredictable multi-step behavior, privacy exposure, and prompt injection.
1. Behind the Hype: The Third Leap in Capability Form
A particular class of agent tooling has recently spread quickly as open source and drawn intense attention within days. Setting aside the buzz, what deserves a developer’s attention is the shift in capability form it represents.
The evolution of how humans interact with programs can be roughly divided into three stages:
- Information retrieval: the user asks a question, the system returns text.
- Generative conversation: the user describes intent, the system generates content, but a human still has to act on the output manually.
- Execution agents: the user issues an instruction, and the system autonomously selects tools, calls APIs, modifies local state, and reports back the result.
The first two stages share one trait: text is the endpoint of the output. In the third stage, the endpoint is a real change in the state of the world. That is the technical meaning of “from chat to action,” and it is the fundamental difference between this kind of tool and an ordinary chat product.
Once that is clear, a common misconception can be cleared up: the hard part is not “a smarter model.” It is the reliable execution infrastructure built around the model. The model makes decisions; reliability comes from the engineering layer.
2. Architecture Overview: A Local Daemon, Not a Web App
From an engineering standpoint, this kind of tool is usually not a conventional web application (separated frontend/backend, stateless requests), nor is it a plain script. It is a daemon that stays resident on the local machine, distributed and configured through the command line, and internally playing three roles at once:
- Ingress: connecting to various chat channels;
- Dispatch: managing sessions, queues, and task lifecycles;
- Execution: calling model APIs and performing real operations on the local system.
There are concrete reasons for this shape. Agent tasks are long-running, stateful, and need access to local resources. A stateless request-response model cannot carry an execution that spans several minutes and multiple tool calls, so execution state has to live in process memory and local storage.
A highly simplified internal structure looks like this:
┌──────────────────────────────────────────────┐│ Local agent runtime (resident process) ││ ││ Channel → Gateway / → Execution ││ adapters scheduler engine ││ (IM, email, (sessions, (tool ││ CLI) queues, ACL) registry, ││ sandboxed ││ calls) ││ ↕ ││ Persistent memory / local files / ││ audit logs │└──────────────────────────────────────────────┘↕ Model inference API (cloud or local)
3. Breaking Down the Key Components
3.1 Channel Adapters: Solving Inconsistent Message Formats
Instant messaging and collaboration platforms differ enormously in message structure, authentication, and attachment handling. If parsing logic is scattered through business code, maintainability collapses fast. The mature approach is one dedicated adapter per source, each doing the same four things:
- Receive and authenticate: verify that the sender is legitimate, so that arbitrary parties cannot issue instructions to a machine-local agent;
- Normalize: convert each platform’s message body into one internal structure;
- Attachment and link extraction: images, documents, and URLs are written to disk or reduced to text before entering the context;
- Session ID mapping: map the platform-side conversation ID to an internal session so contexts never bleed into each other.
A sketch of the normalized structure:
{"sessionId": "s-10086","channel": "im","senderId": "u-42","text": "Summarize tomorrow's schedule and confirm the flight","attachments": [{ "type": "file", "path": "/tmp/in-8821.pdf" }],"receivedAt": "2026-08-26T09:00:00Z"}
3.2 Gateway and Scheduler: Serial First, Parallel Second
This is the most overlooked part of the whole architecture and the one that most affects stability. If instructions in the same session run concurrently, three typical problems appear: interleaved logs that cannot be traced, write races on the same file, and context polluted by whatever message arrives last.
The mainstream design therefore uses a two-lane model: serial within a session, parallel across tasks.
- Each session owns an independent execution lane and processes instructions strictly in order (FIFO) by default;
- Only tasks judged low-risk and mutually independent are allowed into the parallel lane — for example, querying several read-only data sources at once;
- Long-running operations return a “running” acknowledgement so the user does not resubmit.
The strategy in pseudocode:
def dispatch(session, task):if task.risk_level == "read_only" and task.independent:parallel_pool.submit(run, session, task) # safe to parallelizeelse:session.queue.put(task) # serial, order preserveddef session_worker(session):while True:task = session.queue.get()with audit_log(session.id, task.id): # full-chain traceabilityrun(session, task)
The key point: serial by default is the conservative choice; parallelism is an explicit optimization. Reverse that order and the system becomes hard to debug immediately.
3.3 Tool Execution: Capability Boundaries Define Usable Boundaries
An “assistant with hands” is essentially a set of controlled system capabilities: file reads and writes, directory traversal, command-line execution, browser automation, mail and calendar access, HTTP requests, and so on. Three engineering points matter at this layer:
- Declarative registration: every tool declares a name, a parameter schema, a description of its side effects, and a risk level; the model selects tools through structured calls;
- Validation before execution: model output is untrusted, so parameters must undergo strict schema validation and path normalization before running, preventing out-of-bounds reads and writes (for example, escaping the working directory via
../); - Result trimming: tool output can be extremely long and must be truncated or summarized before entering the context, or the context window is consumed almost immediately.
3.4 Persistent Memory: Context Continuity Across Sessions
Chat products typically discard context when a session ends. Execution agents need to remember preferences, progress, and past decisions. The general implementation is tiered storage:
- Short term: the message sequence of the current session, alive for the session’s lifetime;
- Medium term: task state and intermediate artifacts, in local files or a lightweight database;
- Long term: structured preferences and facts, written to a local index and retrieved on demand, then injected into the prompt.
Memory is not better in larger quantities. Long-term memory without eviction and conflict-handling mechanisms makes an agent stubbornly reuse stale information. In practice, add timestamps, source attribution, and explicit override policies.
3.5 Self-Improvement and Container Isolation: Two Sides of Capability and Safety
“Writing its own code to extend its skills” is the most attractive feature of this class of tool: when the agent hits a task it was not preconfigured for, it generates a script, registers it as a new tool, and reuses it in later calls. It also introduces arbitrary code execution onto the local machine, which carries a very high risk level.
Isolation is therefore not optional:
- Run generated code in a container or lightweight sandbox, restricting the visible filesystem scope and network egress;
- Apply least privilege: run under a restricted account, granting only the target directory and the environment variables the work actually requires;
- Put a human confirmation gate in front of high-impact operations (deleting data, sending things externally, payment-related calls);
- Log the entire tool-call chain into a traceable audit trail.
One principle that can go straight into a team standard: an agent’s degree of autonomy should be inversely proportional to the reversibility of the operation. Reversible operations can be left to run automatically; irreversible ones require explicit confirmation.
3.6 How This Differs from AI Coding Tools
A common confusion is worth clearing up: an agent runtime and code-generation tooling solve different problems. The latter targets the specific scenario of “writing code” and is tightly bound to a repository and build pipeline. The former targets general-purpose task execution, emphasizing cross-channel interaction, access to local resources, and orchestration of multiple tools. The two can be combined — coding ability is just one tool among many for an agent.
4. Implementation Checklist
To build comparable capability in your own environment, proceed roughly in this order:
- Narrow the scope first: pick 2–3 high-frequency, low-risk, verifiable tasks (inbox triage, schedule summaries, report generation). Do not chase generality on day one.
- Define the permission model: state which directories are writable, which APIs are callable, and which operations need confirmation, and make the policy configurable.
- Build scheduling and auditing: a serial queue plus structured logs is the foundation of reliability and should come before model tuning.
- Isolate the execution environment: run in containers, restrict network egress, keep secrets out of images.
- Add evaluation: build a repeatable test set per task and measure results with pass rates rather than subjective impressions.
- Split work with the cloud: the local process handles sensitive data and local resources, while heavy workloads can be offloaded to general-purpose cloud services — large-model inference, object storage, message queues, container platforms, logging, and monitoring and alerting. Providers such as Baidu AI Cloud offer exactly these general-purpose service categories, which makes them easy to consume on demand and observe under a single pane of glass.
- Control cost: set timeouts, retry limits, and usage quotas on model calls so long tasks cannot run away.
5. Risks and Boundaries
The inherent weaknesses of this architecture have to be acknowledged:
- Error amplification: one bad judgment by an agent can corrupt real data directly, and without a rollback mechanism the cost is high;
- Not fully predictable: the combinatorial explosion of multi-step autonomous decisions makes exhaustive testing unrealistic;
- Privacy-sensitive: running resident on the local machine with access to mail and calendar means very high data sensitivity, so retention and deletion policies must be explicit;
- Prompt injection: malicious text in external documents, web pages, or emails can hijack decisions, so untrusted content must be isolated and labeled as such.
6. Conclusion
On the surface, these tools went viral because the interaction model is intuitively appealing. The deeper reason is that they offer a pragmatic engineering answer: a resident local process to hold state, a channel-adapter layer to meet people where they already are, a serial-first queue to buy predictability, and container isolation to contain the risk of autonomy. For individual users it is an assistant that handles chores; for engineering teams it is a reference architecture for an “agent runtime” worth studying. What ultimately determines results is never the model itself, but whether the scheduling, permission, and audit systems built around it are rigorous enough.
