AI Infra for Agents: Rebuilding the Stack Around Token Economics
As AI workloads shift from chat to agents, the cost per million tokens becomes the defining constraint. This article breaks down why agent workloads break traditional inference stacks, where the bottlenecks appear across memory, compute, networking, and billing, and how to rebuild the infrastructure for efficient token production, delivery, and application. It also outlines a phased adoption roadmap and the key metrics to track.
1. The Token Consumption Shift: From Chatting to Doing
Three years ago, when large language models first reached the mainstream, global LLM token consumption was concentrated in conversational Q&A and search-augmented scenarios. The interaction pattern was a single question followed by a single answer: short contexts, short sessions, and few tool calls. Three years later, the picture has inverted. Agent applications and AI coding tools together account for the vast majority of global LLM token consumption, while traditional chat and search have moved to the margins.
This is not merely a change in ratios; it is a change in the nature of the workload. Chat workloads have relatively balanced input and output, with short session lifecycles. Agent workloads, by contrast, exhibit three distinct characteristics:
- Extremely long contexts: a single task often carries hundreds of thousands of input tokens, including system prompts, tool definitions, historical trajectories, and retrieved snippets.
- High-frequency tool calls: model output must be parsed, executed, and fed back, forming a multi-turn “reason-act-observe” loop.
- Strong statefulness: tasks require consistent goals, memory, and constraints across turns, and any interruption means rework.
The conclusion is straightforward: an inference stack designed around chat assumptions suffers systemic efficiency collapse under agent workloads.
2. The 2035 Quantitative Outlook and a Hard Economic Constraint
Looking toward 2035, the industry commonly projects that the number of agents worldwide will reach the hundreds of billions, annual token consumption will grow by orders of magnitude of ten thousand, and token-driven economic value will reach the quadrillion scale, making tokens the “digital currency” of the intelligent economy.
But whether this vision materializes depends on one hard constraint: the cost per token must fall fast enough. It can be written as an inequality:
Sustainable value = Token price decline rate ≥ Token demand growth rate
If the cost per token falls more slowly than demand grows, the total bill rises exponentially, and the application layer is forced to cut task complexity, capping agent capability by economics. Therefore, the core problem for AI infrastructure is not to push peak performance as high as possible, but to drive the combined cost per million tokens low enough while keeping latency in a usable range under long contexts and high concurrency.
3. Locating the Bottlenecks: Four Pressure Points Under Agent Workloads
- The memory capacity wall. Long contexts cause KV cache to expand linearly, and a single request can consume tens of GB of memory, severely squeezing batching space.
- The compute utilization wall. The decode phase is memory-access intensive, leaving compute units largely idle; the prefill phase is compute intensive, and running the two together causes interference.
- The scheduling and network wall. Tool calls lengthen request lifecycles and scatter state, increasing cross-node communication and state synchronization overhead.
- The unpredictable billing wall. Retries, extremely long contexts, and failure rollbacks all amplify token consumption, and costs spiral out of control without observability.
4. Rebuilding the Foundation: Efficient Token Production
The goal is to increase effective throughput per unit of hardware. Common approaches include:
- Tiered KV cache: place KV by热度 across GPU memory, host memory, and remote cache pools, combined with prefix sharing so system prompts and tool definitions are computed only once.
- Prefill and decode disaggregation: deploy the two workload types separately and scale them independently to avoid interference and improve overall utilization.
- Low precision and quantization: use low-precision weights and caches within an acceptable accuracy range to reduce memory-access pressure.
- Speculative decoding: use a small model or draft mechanism to guess ahead, then have the main model verify, reducing the number of serial decode steps.
Illustrative scheduling pseudocode:
def route(request):if request.hit_prefix_cache():return pool_prefill if request.is_prefill_heavy() else pool_decodeif request.est_tokens > LARGE_CTX_THRESHOLD:return pool_long_context # Dedicated long-context pool to avoid slowing down short requestsreturn pool_general
5. Rebuilding the Foundation: Efficient Token Delivery
The agent “reason-act-observe” loop imposes new requirements on networking and state management:
- Event-driven transport: use message queues and streaming channels to carry tool calls and result feedback, avoiding idle long-lived connections.
- Externalized state: write task context to low-latency storage and caches so instances can recover after restarts and support elastic scaling.
- Structured output constraints: constrain generation with schemas to reduce retries caused by parsing failures.
- Full-chain observability: build logs, metrics, and alerts with tokens as the unit of measure, attributing costs by tenant, task, and tool.
6. Rebuilding the Foundation: Efficient Token Application
The benefits of infrastructure must ultimately be realized at the application layer:
- Context engineering: inject retrieved snippets on demand and compress and summarize historical trajectories to minimize wasted tokens.
- Cache first: use semantic caching and result reuse so repeated tasks are not paid for repeatedly.
- Tiered model routing: assign simple subtasks to small models and complex reasoning to large models, trading cost-performance for scale.
- Budgeted execution: set token and latency budgets for each task, and degrade gracefully when exceeded rather than retrying indefinitely.
7. Adoption Roadmap and Metrics
A three-phase approach is recommended: first establish observability and budget constraints, then add caching and tiered routing, and finally implement disaggregated deployment and externalized state. Metrics should cover cost per million tokens, time to first token, task completion rate, cache hit rate, and energy consumption per task. For related general-purpose capabilities, Baidu AI Cloud typically offers support categories such as container platforms, object storage, message queues, log services, and monitoring and alerting, which can serve as general-purpose building blocks for such a foundation.
The reversal of the token landscape shows that the second half will not be won on parameters but on system-level reconstruction: whoever can produce tokens more cheaply, deliver them more smoothly, and apply them more precisely holds the pricing power of the intelligent economy.
