AI Agent Frameworks: The Battle Between Gateway and Runtime
As AI agents move from niche tools to mass-market products, many early architectures built around a long-running gateway process start to fail under scale. This article breaks down a typical "gateway-first" agent design, explains four structural bottlenecks that emerge as user bases grow, and outlines a shift toward a lightweight gateway paired with a robust runtime. It covers separating the control and execution planes, decoupling skill declarations from execution, sandboxed execution, built-in observability, and a gradual approach to multi-agent collaboration, along with practical selection advice for developers, enterprise users, and platform providers.
AI agents are evolving at a pace that feels like a new release every month. A few months ago, a class of systems that used instant messaging as the entry point and could operate a browser, call APIs, and read or write local files in the background went viral. The slogan in the community was roughly this: a chatbot gives up when it hits a problem, while an agent finds a way around it. Many people experienced for the first time what it felt like to remotely command a digital avatar to do work for them: send a voice message, and it would clean up your inbox, scrape web pages on a schedule, or even negotiate with merchants on your behalf.
But before that throne even warmed up, a new generation of solutions appeared and started topping the charts. Posts saying “I just fixed the errors in the previous setup, and after seeing the new approach I migrated overnight” were everywhere. This was not simply a case of chasing novelty. It reflected a recurring engineering pattern: when the user base expands from a few thousand geeks to millions of ordinary people, the architectural trade-offs made early on for the sake of “usable and fun” turn into concentrated problems of stability, security, and cost.
1. Sample Breakdown: A Heavy Orchestration Engine Built Around a Gateway
The system in the original discussion is a typical “gateway-first” design. Its core is a long-running resident service process that handles message ingestion, session state management, task orchestration, and plugin scheduling. Capabilities are extended through plugins, and skills are often described in a structured specification file that is effectively hard-coded, including trigger conditions, available tools, constraints, and output formats. This also gave rise to a community joke about “distilling a colleague’s experience into a skill file.”
A typical scenario is competitor price monitoring for cross-border operations: the user wants to visit several overseas sites on a daily schedule, scrape prices, merge and deduplicate them, and then deliver the results to their inbox. In this system, the implementation path usually goes like this: obtain web scraping and email plugins from the open-source community, write the skill specification file, configure a scheduled task, and then issue instructions in the chat window. The system calls the plugins in orchestration order to complete the task. For more complex workflows, it can also have multiple agents divide the work in the background.
The advantages of this design are clear: a low entry barrier (everyone knows how to use a chat app), capability expansion through an ecosystem, and centralized, auditable orchestration logic. But its Achilles’ heel is equally obvious.
2. Where the Bottlenecks Come From: Four Structural Problems Amplified by Scale
1) A single long-running process. All sessions, tasks, and plugins hang off one long-running service. A single memory leak, an infinite loop, or a failed dependency upgrade affects all users. Hot updates and canary releases are almost impossible.
2) Blurred capability boundaries. Plugins typically run directly on the host machine with the same file system and network permissions as the user. Prompt injection, malicious web content, or a poisoned community plugin can all turn into local data leakage or accidental deletion.
3) Coupling of state and orchestration. Session context, intermediate task artifacts, and scheduling metadata are mixed within the same process. This means the system loses memory on restart, cannot scale horizontally, and struggles to resume from a checkpoint.
4) Lack of cost control and observability. A long-running process combined with repeatedly feeding the full context into the model causes token consumption and API costs to grow linearly or even super-linearly with the number of users. If logging, metrics, and tracing are not designed in from the start, troubleshooting comes down to “reading the error messages.”
3. The Direction of Evolution: Slim Down the Gateway, Build Up the Runtime
To serve a mass audience, the architectural focus needs to shift from a “heavy orchestration gateway” to a “lightweight access layer plus a strong runtime.” There are five practical lines of improvement.
(1) Separate the control plane from the execution plane. The access layer should only handle protocol adaptation, authentication, rate limiting, and session routing. The execution layer should use short-lived tasks to carry out the actual work, with task state stored externally in a database or object storage. This supports restart-and-resume and horizontal scaling.
(2) Decouple skill declarations from execution. Upgrade skills from “hard-coded specification files” to manifests with versioning and permission declarations, and have the runtime dynamically assemble tools based on least privilege. An example is shown below:
skill:name: price-monitorversion: 1.3.0schedule: "0 8 * * *"tools:- fetch_url: { allow_domains: ["example-a.com", "example-b.com"] }- transform: { max_rows: 5000 }- notify_mail: { to: "ops@example.com" }limits: { timeout_s: 120, max_tokens: 8000, retries: 2 }
(3) Sandboxed execution. Put high-risk actions such as scraping, parsing, and code execution into containers or micro virtual machines. Create them on demand and destroy them after use, mount only the necessary directories, and route outbound traffic through a whitelist proxy. Even if prompt injection occurs, the damage is confined to a disposable environment.
(4) Built-in observability. Use a unified trace_id that runs through “message, plan, tool call, and model call.” Turn token usage, tool failure rate, and task duration into metrics with alerts configured. Keep replayable audit records for high-risk actions.
(5) Gradual multi-agent adoption. Multi-agent collaboration offers high value but is hard to debug. The recommendation is to first get a closed loop running with a “single agent plus tool orchestration,” then gradually open up collaboration permissions by tier: read-only, controlled write, and high-risk write.
4. Selection and Practical Advice for Different Readers
For developers: prioritize evaluating three things: whether state is externalized, whether execution is isolated, and whether skills are versionable. If any of the three is missing, rework is inevitable once scale arrives. When building in-house, you can assemble a runtime foundation from common capabilities such as a message queue, a container platform, object storage, and logging with monitoring and alerting, avoiding welding business logic to the access protocol.
For enterprise users: draw the red lines before talking about efficiency. Define which data is allowed to leave the local machine, which actions require human confirmation, and how long audit records are retained. Limit agents to read-only or controlled-write scenarios in a pilot, and use quantifiable metrics (task success rate, average duration, human takeover rate, and cost per task) to decide whether to expand the scope.
For platform providers: cloud vendors such as Baidu AI Cloud, which offer containers, storage, messaging, and observability services, provide value by standardizing the foundation described above, allowing upper-layer agents to focus on business orchestration. Specific capability selection should be based on the official documentation and hands-on testing, not community rumors.
5. Conclusion
The shift from “gateway-first” to “runtime-first” is essentially a necessary path for agent frameworks to move from geek toys to infrastructure. The entry point can be lightweight, but state, isolation, permissions, and observability must be built up solidly. Once you understand this main thread, you will not feel anxious about “starting too late.” What has always been truly scarce is not any particular framework, but the engineering capability to run agents safely, controllably, and affordably in production environments.
