LLM API Evolution: From Message Primitives to Agent Runtime
LLM APIs are evolving along two paths: interface replacement and layered stacking. This article focuses on the layered approach, where the message primitive stays the stable core and higher-level capabilities—agent runtimes, built-in tools, context compaction, persistent memory, and managed platforms—stack on top of it rather than replacing it. It breaks down what each layer offers in terms of control granularity, implementation cost, and risk, explains where to draw the line between self-building and using a runtime, and offers practical guidance for choosing integration depth: subtract at the orchestration layer, and add at evaluation, permissions, and cost.
Introduction: Two Evolution Paths, One Shared Goal
Over the past two years, the evolution of LLM APIs has gradually split into two distinct styles.
One path is interface replacement: launching an entirely new runtime interface that integrates multi-turn conversation, tool calling, built-in tools, and state management into a new request paradigm, while the original chat completion interface retreats to a compatibility layer.
The other path is layered stacking: holding onto the stable primitive of “messages in, structured content blocks out,” and layering on top of it, one by one, the agent runtime, an AI coding tool kernel, and a managed agent platform, letting developers choose their integration depth according to the control granularity they need.
Both paths share the same goal: to turn “models that can call tools” into “agents that can complete tasks.” The difference lies in where the compatibility contract is placed. This article focuses on the second path—how LLM APIs evolve from message primitives into a managed agent platform—and what this evolution means for technical selection.
I. The Evolution Mainline: Primitives Aren’t Replaced; Capabilities Move Upward
To judge whether an evolution path is sustainable, you can observe three things: what the stable core is, how incremental capabilities are delivered, and whether old code needs to be rewritten.
The layered stacking path answers:
- The stable core is the message interface. Its request and response structure remains unchanged over the long term, so the SDKs, toolchains, and teaching materials built around it won’t break.
- Incremental capabilities are delivered additively. Capabilities such as context compaction, persistent memory, agent hosting, built-in toolsets, and permissions and hooks appear layer by layer, each built on top of the primitive rather than overturning it.
- Old code doesn’t need rewriting. Teams using only the message interface can keep orchestrating things themselves and adopt higher-level capabilities whenever they want.
By contrast, the interface replacement path reorganizes concepts around a new interface, and old code usually needs migration and adaptation. Neither path is absolutely superior. When making a selection, ask one question: how much engineering effort are you willing to pay for “control,” and how much control are you willing to give up for “managed service”?
II. The Message Primitive Layer: Finest Control Granularity, Most Complete Responsibility Boundary
The design philosophy of the message primitive is simple: take a set of role-tagged messages as input and produce a response composed of several content blocks as output. Tool calls, reasoning process, and final text are all just different types of content blocks. Precisely because the structure is simple, it can carry fairly complex workflows.
1. Key Capabilities
Tool use: Developers declare available tools with schemas, and the model decides on its own when to call them, returning a structured block with call arguments in the response; after executing the tool, the developer sends the result back as a new message. This is the foundation of agent behavior.
Extended thinking: The model first outputs a reasoning content block, then gives its conclusion. Three points are worth noting in practice: reasoning content can be carried across turns to maintain the continuity of reasoning; the thinking budget can be capped to balance reasoning depth against response latency; in sensitive scenarios, the thinking process should be treated as internal information and not shown directly to end users.
Prompt caching: Stable prefixes such as system prompts, tool definitions, and long documents can be cached and reused, and input-side billing typically drops significantly on a cache hit. The prerequisite is that the prefix is byte-for-byte stable, so volatile content (timestamps, random IDs, session state) should be placed at the end of the prompt.
Structured output: Constraining model output with a JSON Schema makes the result directly parseable by downstream programs, reducing the rework caused by “the model speaks in prose but the program can’t read it.”
Server-side hosted tools: Tools such as web search, web scraping, and code execution run on the platform side, with results returned as special content blocks, eliminating the need to build your own proxy network and execution sandbox.
2. Advantages and Costs
The advantage is the finest control granularity: the complete agent loop, context assembly, tool execution, retries, and fallbacks are all in your own hands, which makes deep customization and compliance auditing easier.
The cost is equally clear: loop control for multi-step tool calls, parallel subtasks, session state persistence, history compression, failure recovery, and cost attribution all need to be implemented yourself. This engineering effort is often underestimated—the gap between a demo that “works” and an agent that “can go to production” is precisely these things.
3. A Minimal Agent Loop
# Illustrative code: a minimal tool-calling loop on top of the message primitive (pseudocode, not a specific platform API)messages = [{"role": "user", "content": "Locate and fix the failing unit tests in the repository"}]for step in range(MAX_STEPS):resp = client.create(model=MODEL,system=SYSTEM_PROMPT, # placed first to favor prompt-cache hitstools=TOOLS, # JSON Schema definitions of the toolsmessages=messages,)messages.append({"role": "assistant", "content": resp.blocks})calls = [b for b in resp.blocks if b.type == "tool_use"]if not calls:return resp.text # no tool call, task wraps upresults = [dispatch(c) for c in calls] # executed locally or in a sandbox; always enforce permission checksmessages.append({"role": "user", "content": results})
This code is under twenty lines, but it is still short of production-ready: timeouts and retries, tool-argument validation, an execution sandbox, trace logging, context-budget control, and cost caps.
III. The Agent Runtime Layer: Turning the Agent Kernel into a Library
The key change at the second layer isn’t a new interface, but turning the agent’s execution kernel itself into a library—opening up the same runtime that drives comparable agent products as an embeddable SDK. Its value lies in implementing for you those parts that are “easy line by line, but annoying together”:
- Built-in toolset: file read/write and editing, code retrieval and text matching, command and test execution, web search and scraping, and reusable skill packaging. Tool descriptions, argument validation, result truncation, and error-return formatting are all aligned, so the model’s tool-call success rate is higher.
- Lifecycle and state: a task, a session, and a working directory each correspond to a well-defined runtime unit, so you no longer need to design “what a session actually is” yourself.
- Permissions and hooks: insert validation, approval, rewriting, and auditing logic before and after tool execution, turning “which operations must be manually confirmed” into a configurable policy.
- Subagents and task decomposition: hand large-scope retrieval and parallel exploration to subtasks, with the main context keeping only conclusions—this is a core technique for handling long tasks.
Two Integration Forms
| Integration form | Characteristics | Suitable scenarios | Things to note |
|---|---|---|---|
| One-shot task-style call | Stateless; pass in a prompt and execute; get started with a little code | Batch processing, automated fixes in CI, offline data processing | Lacks multi-turn context; you must design file and result passing yourself |
| Long-lived session-style client | Stateful; supports multi-turn interaction, hooks, permission control, and interruption and recovery | Interactive assistants, IDE-style integrations, long-running tasks | Requires managing session persistence and concurrency limits |
The Dividing Line Between Self-Building and Using a Runtime
You can draw the line with three questions:
- Do you need fine-grained control over context assembly (picking history item by item, custom compression algorithms)? If so, lean toward self-building.
- Is your toolset highly domain-specific (internal proprietary systems, special protocols)? If so, you need to build the execution layer yourself, but you can reuse the runtime framework.
- Do you need deep coupling with the host product’s permission system and audit chain? If so, prefer a runtime that offers a hook mechanism rather than a fully managed solution.
IV. The Managed Platform Layer: Handing the Ops Burden to the Platform
The third layer moves up further: task definition, execution environment, context compaction, persistent memory, tool authorization, concurrent scheduling, and observability are all managed by the platform. Developers only describe the task and its constraints, and the platform is responsible for running it to completion.
This layer solves some of the hardest things in long tasks and team collaboration:
Compaction. No matter how large the context window is, it is finite. When history approaches the limit, early content needs to be compressed via summarization while preserving the task goal, key decisions, the list of modified files, and open questions. Good compaction should guarantee that “the task is recoverable,” rather than simply discarding early turns.
# Illustrative code: compact history near the budget, preserving instructions and recent turnsdef maybe_compact(messages, budget):if estimate_tokens(messages) < budget:return messageshead = messages[:2] # system instruction and task definitiontail = messages[-6:] # recent turns, including the latest tool resultmiddle = messages[2:-6]summary = summarize(middle,keep=["goal", "confirmed decisions", "modified files", "failed approaches", "to-dos"],)return head + [{"role": "user", "content": summary}] + tail
Memory. Write stable information that spans sessions (project conventions, code style, user preferences, past conclusions) into a readable and writable memory store, and retrieve and inject it on demand in subsequent tasks. The hard part of memory isn’t writing, but governance: who can write, whether entries are reviewed before being written, how expiration and conflicts are resolved, and how sensitive information is redacted.
Hosted execution and scheduling. Checkpoint resume for long tasks, failure retries, concurrency isolation, and resource quotas go from “your own service has to withstand it” to “the platform guarantees it.” The cost is reduced visibility into low-level behavior, so troubleshooting relies on traces and logs provided by the platform.
Three-Layer Capability Comparison
| Dimension | Message primitive layer | Agent runtime layer | Managed platform layer |
|---|---|---|---|
| Control granularity | Finest, controllable block by block | Medium, intervenable via hooks | Coarser, input is tasks and constraints |
| Implementation cost | High, all orchestration self-built | Medium, focus on business logic | Low, focus on task definition |
| Context governance | Fully autonomous | Framework-provided, partially customizable | Platform automates compaction and management |
| Observability | Self-built instrumentation | Runtime events + self-built logs | Platform traces dominate |
| Main risk | Engineering effort and stability | Coupling with the host | Data boundaries and portability |
| Typical scenarios | Strong customization, strong compliance | Agents embedded in a product | Batch processing, long-running tasks, team collaboration |
V. Practical Recommendations: Choose Integration Depth by Control Granularity
Move up gradually; don’t do it all at once. First get the task working with the message primitive, and clarify “which orchestration is a business differentiator and which is just a general pipeline.” Hand general pipelines to the runtime or platform first, and keep business differentiators in your own hands.
Leave room for migration. Abstract a thin wrapper layer in your own code that isolates model calls, tool registration, context assembly, and memory read/write in the inner layer. When you switch integration levels or model versions in the future, changes stay within the wrapper and business code stays untouched.
Manage context as a budget. Define the per-task token cap, the compaction trigger threshold, the tool-result truncation length, and the subtask count cap. Context management isn’t “the more you stuff in, the better”—ultra-long context offers no advantage in either reasoning quality or cost, and compaction and retrieval are often more effective.
Front-load permissions and auditing. Once an agent can write files, execute commands, and access the network, least privilege, operation whitelists, manual confirmation for dangerous operations, and full trace retention are baseline requirements, not options.
Make costs controllable. Prompt-cache hit rate, thinking budget, subtask parallelism, and retry caps are the four main levers. Before launch, run load tests and canary rollouts, and set a hard cap on per-task cost.
Build the evaluation system first. Establish a task-level evaluation set (including failure samples) and continuously track task success rate, tool-call accuracy, average steps, and per-task cost. Agent behavior fluctuates far more than a single Q&A, and without evaluation there is no regression capability.
VI. Risks and Boundaries
- Capabilities ship at different paces. High-level capabilities often appear before low-level interfaces, and their behavior may change with versions. Key paths should have regression tests to avoid “upgrade equals breakage.”
- Abstraction leaks. What a managed layer “does automatically” may not match your expectations, especially compaction strategies and tool selection. In scenarios where explainability is insufficient, you should still retain control at the primitive layer.
- Data boundaries. Hosted execution means code, logs, and context leave the local environment. For scenarios with strict compliance requirements, confirm the data-processing location, retention policies, and deletion mechanisms in advance.
- Don’t reinvent the wheel. Session persistence, context compaction, and tool sandboxes are the three things with the highest self-build cost and the least business differentiation, and are usually the first things to hand off to a managed service.
Conclusion
The evolution of LLM APIs is essentially the gradual takeover of “the agent’s general pipeline” from the developer’s hands. The message primitive won’t disappear; it is the compatibility contract and the final point of control. The runtime and the managed platform are efficiency levers that determine how fast you can get an agent to production.
The practical implication for developers is direct: subtract at the orchestration layer, and add at evaluation, permissions, and cost. Investing the engineering effort you save into business differentiation and quality assurance is where the real dividend of this round of evolution lies.
Cloud providers are organizing their capabilities along similar lines as well. Baidu AI Cloud, for example, offers model-serving APIs, agent development and orchestration, and a one-stop managed form through its Qianfan model platform, letting developers switch integration depth across different control granularities as needed.
