Large Model API Evolution: From Message Primitives to Managed Agent Runtimes
As LLM APIs enter the Agent era, platform providers face a fundamental infrastructure choice: expose atomic message primitives, or deliver orchestration, recovery, and compression as a managed runtime. This article breaks down the three-layer capability stack — the L0 message primitive layer, the L1 agent framework layer, and the L2 managed platform layer — and explains what each layer is responsible for, what it costs to build yourself, and how to choose the right integration depth. It also covers five practical recommendations for a gradual, evaluation-driven evolution, plus a cloud infrastructure perspective. The goal is simple: make control granularity a choice rather than a constraint.
1. The Core Debate: Primitives First or Runtime First?
Once large model APIs move into the agent phase, a classic infrastructure disagreement emerges: what should the platform actually provide? One position is primitives first — expose an atomic message round-trip interface and hand loop control, state management, and tool dispatch back to the developer. The other position is runtime first — build multi-step task orchestration, recovery, and compression directly into the platform, so developers integrate by configuration alone.
Both positions have merit. Primitives first offers replaceability, debuggability, and no lock-in: each inference request is a replayable, diffable call, and when something goes wrong you can trace it back to a specific input and output. Runtime first is valuable because real production complexity rarely lives in a “single inference call.” It concentrates in the things around inference: tool call retries, parallel subtasks, trimming when context runs too long, session recovery across days, and audit trails. Build each of those pieces yourself, and your team will soon discover it has rebuilt an agent platform.
Looking at the paths of today’s mainstream providers, the two approaches are not mutually exclusive. The more common pattern is to keep the message primitive stable and layer runtime capabilities on top of it, letting developers choose their integration depth based on the control granularity they need: stop at the primitive layer for fine-grained control, move up to the framework layer for efficiency, or hand off to the managed layer for operations and compliance. Understanding this layered structure matters more than memorizing any one provider’s specific interface names — it determines how much room your architecture has to evolve.
2. Splitting the Capability Stack into Three Layers
| Layer | Responsibility | Control Granularity | Typical Users |
|---|---|---|---|
| L0 Message Primitive Layer | Input/output semantics and capability switches for a single inference call | Finest, fully autonomous | Teams that need custom scheduling, auditing, and multi-model routing |
| L1 Agent Framework Layer | Tool sets, hooks, context compression, subtask orchestration | Medium, pluggable | Teams that need to quickly build coding/retrieval/analysis agents |
| L2 Managed Platform Layer | Sessions and memory, checkpoint recovery, sandboxing, metering, version management | Coarsest, configuration-driven | Teams that need to ship agents as operable services |
The shared premise of all three layers is this: upper layers do not replace the layer below; they reuse its semantics. Once the message block structure is stable, frameworks and platforms can all build on the same abstraction, making the upgrade path continuous rather than a rewrite-and-migrate exercise.
3. L0: Making the Message Primitive Powerful Enough for Complex Agents
Early conversational interfaces had very simple semantics: a set of role-tagged text messages goes in, a piece of text comes out. Interfaces built to support agent workflows have made several key extensions on that same semantic skeleton.
Responses become structured content blocks. Model output is no longer plain text; it is a sequence of typed blocks — for example, plain text blocks, tool call blocks, and reasoning blocks. This change looks small but has a large impact: callers no longer need regexes or delimiters to parse “what tool the model wants to call.” Tool calls become first-class citizens, and frontend rendering, executor dispatch, and log archiving can all branch by type.
{"role": "assistant","content": [{ "type": "thinking", "thinking": "First check whether the target file exists, then decide on a read strategy" },{ "type": "tool_use", "id": "call_01","name": "read_file", "input": { "path": "./config.yaml" } }]}
Cross-turn propagation of thinking and reasoning blocks. Some services support returning explicit reasoning blocks and allow passing prior reasoning blocks back unchanged in later turns. The value is not just “seeing what the model is thinking.” More importantly, in multi-step tasks the reasoning context carries forward, reducing information loss across turns; meanwhile the reasoning content can be trimmed and audited separately, without being mixed with user-visible text.
Prompt caching. By marking reusable prefixes (or hitting the cache at block level or automatically), stable content such as system prompts, tool definitions, and long documents can be cached. Three engineering guidelines apply: put volatile content at the tail of the prompt, put large stable blocks up front, and avoid modifying the prefix on every turn, which would invalidate the cache. Cached portions are typically billed at a significantly lower rate; the exact discount and invalidation policy depend on the billing rules of the service you choose.
Structured output constraints. Use a schema such as JSON Schema to constrain output at the decoding stage, replacing the fragile “generate, then parse, then retry on failure” pipeline. For downstream cases like database writes, form filling, and function arguments, this is a key piece of stability.
Server-side hosted tools. Tools like web search, page fetching, and code sandbox execution can be run by the platform server-side, with results filled back in. This removes the cost of building your own retrieval infrastructure, proxy pools, and sandbox isolation, and turns “tool calls” from internal application behavior into observable platform-side events.
The cost of this layer must also be counted. Multi-step tool call loops, failure retries and idempotency, session state persistence, context compression when context runs too long, sub-agent orchestration, and concurrency and rate limiting — all fall on the developer. The primitive layer gives the greatest freedom, and it corresponds to the greatest engineering debt.
4. L1: The Agent Framework Layer — Keep Control, Add Orchestration Infrastructure
The core idea of the framework layer is: it does not change who owns the agent loop, but turns the parts you repeatedly write into default capabilities.
Built-in tool sets out of the box. Common general-purpose tools include file reading, writing, and partial editing; command execution; directory and filename matching; content search; web search and page fetching; and an extensible skills/plugin mechanism. For coding, retrieval, and data-analysis agents, these tools cover most high-frequency actions, so the team can focus on the business semantics layer.
Lifecycle hooks. Frameworks typically expose a dozen or more hook points at key moments — for example, before a tool call, after a tool call, when a sub-agent starts and ends, before context compression, and at session start and end. The value of hooks is to decouple governance from logic — you do not need to fork a copy of the agent loop to insert your own code:
def before_tool_call(event, ctx):if event.tool == "write_file" and not is_in_workspace(event.input["path"]):return deny("Out-of-bounds write blocked")if not passes_policy(event.tool, ctx.user):return deny("Permission policy does not allow this operation")audit.log("tool_call", user=ctx.user, tool=event.tool, args=redact(event.input))return allow(modified=event.input) # Can also rewrite arguments to enhance behavior
There are four typical engineering uses: audit trails (every call is traceable), blocking/interception (permission and compliance red lines), behavior modification (rewriting arguments, adding context), and rate limiting/quotas (controlling call frequency per tenant).
Context compression and memory. Long sessions inevitably overflow the window, so the framework layer typically provides compression strategies: summarize past turns, keep key decisions and tool results, and discard redundant output. Memory is split into working memory (the current session) and long-term memory (cross-session preferences and project conventions), where the latter requires external storage support.
Sub-agents and parallel orchestration. Splitting a complex task into several independent subtasks and handing them to sub-agents — each holding its own context and returning only its conclusion — is an effective way to control growth of the main context.
5. L2: The Managed Platform Layer — Turning the Runtime into Operable Infrastructure
When agents move from demo to production, teams run into a batch of problems unrelated to model capability. The value of the managed platform layer is precisely in taking on these operational properties: hosted persistence of sessions and memory, checkpoint recovery and scheduling for long-running tasks, sandboxes and least-privilege isolation for tool execution, end-to-end observability and auditing, tenant-level metering and quotas, and version management and canary releases for agent definitions and tool sets.
To judge whether you need a managed layer, ask three questions: will the task run for tens of minutes or more and may be interrupted? do you need to explain the basis of every tool call to an external auditor? do you need cost attribution and rate limiting by tenant or business line? If even one answer is yes, the cost of building it yourself will quickly exceed the cost of integrating.
6. Selection Criteria for the Three Integration Depths
- Choose L0: you need multi-model routing and your own scheduling, you have extremely high requirements for reproducibility of a single request, or you are in a strongly regulated environment and must control data flow yourself.
- Choose L1: the target is agents that are “tool-heavy but with clear boundaries,” such as coding assistants, retrieval Q&A, and operations analysis, and the team wants to deliver within weeks.
- Choose L2: the agent faces external users or is reused across departments, and requires SLAs, auditing, quotas, and version governance.
Two common anti-patterns are worth watching out for. One is building too early: assembling a full orchestration framework before requirements are clear, so that in the end you are maintaining the framework instead of the business. The other is outsourcing too early: locking core business logic into a platform’s proprietary agent definition and losing the ability to debug locally and to replace it.
7. Implementation Practice: Five Recommendations for Gradual Evolution
- Build a unified abstraction layer inside the application. Use an adapter pattern to wrap the four steps of “build message — make the call — parse content blocks — dispatch tools,” so business code depends only on your own intermediate structures. When switching providers or mixing models from multiple vendors, the change is contained within a single module.
- Evolve in the order L0 → L1 → L2. First get a closed loop running on primitives and build up an evaluation set, then push repeated orchestration down into the framework, and finally hand the capabilities that need operations to the managed platform. At each step, use the existing evaluation set as a regression baseline.
- Treat hooks as a governance surface, not an extension point. Implement permission checks, redaction, and auditing through hooks as much as possible, to avoid intruding into the agent’s main logic and to minimize conflicts when the framework is later upgraded.
- Control cost at three levels. The first level is prompt caching, to eliminate repeated prefixes; the second is tiered model routing, where simple intents go to small models and complex reasoning goes to large models; the third is output length and tool-result truncation, to prevent unchecked context growth.
- Observability must cover the tool chain. Recording only model inputs and outputs is not enough; you need to record each tool call’s arguments, duration, a summary of the return value, and the failure reason — only then can you locate the real cause of an agent “going down the wrong path.”
8. A Cloud Combination Perspective
For teams using cloud platforms such as Baidu AI Cloud, the three layers above can map to concrete infrastructure combinations: the model inference service provides message primitives and capability enhancements (reasoning blocks, caching, structured output, hosted tools), the agent development and hosting platform carries framework-layer and platform-layer capabilities, and the surrounding infrastructure is handled by the container platform for runtime and elastic scaling, object storage for long documents and artifacts, a message queue to decouple long-running tasks, logging and monitoring/alerting services to close the observability loop, and a key management service to manage credentials centrally. The key is to keep the business side depending only on the abstraction layer, so that the infrastructure stays replaceable and capabilities can be added incrementally.
Conclusion
The direction of large model API evolution is not to replace an old interface with a new one, but to keep layering runtime capabilities on top of stable primitives. For developers, the practical meaning is that control granularity can be chosen, not dictated. First make full use of the message primitive, then decide where to stop based on your team’s real bottleneck — this is more reliable than chasing any one provider’s feature list.
