[KongchangAI]
· 2 min read· 1,391 words

LLM Agent Batch Tasks Speed Up by 65%: Joint Inference-Environment Optimization

LLM Agent Batch Tasks Speed Up by 65%: Joint Inference-Environment Optimization

Ant Group's Ling team proposes joint inference-environment optimization that cuts Agent batch task makespan by 10.4%–65.0%.

To address the efficiency bottleneck caused by the "reason—act—observe" loop in LLM Agent batch tasks, Ant Group's Ling team proposes a joint inference-environment optimization approach centered on batch makespan. The method includes: a workload resource model to guide KV cache and recurrent state memory allocation for hybrid-architecture LLMs to reduce recomputation; trajectory-aware routing and scheduling balancing prefix cache reuse with worker load balancing; and CAAS scheduling under constrained environment capacity to prioritize long chains and compress the batch tail. On BFCL, SWE-bench Multilingual, WideSearch, and MCP-Atlas, makespan is cut by 10.4%–65.0% with scores aligned, and it has been applied to Ling-3.x model training and evaluation.

The efficiency of batch task execution for LLM Agents is becoming a key bottleneck constraining model training and development workflows. Whether it's benchmark evaluation, synthetic data generation, or rollout in reinforcement learning, these tasks all share the same characteristic: repeatedly switching between LLM inference and environment interaction. A new study from Ant Group's Ling team proposes a joint inference-environment optimization approach that achieves a 10.4% to 65.0% reduction in batch makespan across multiple benchmarks, while keeping evaluation scores aligned.

LLM Agent Batch Task Joint Inference-Environment Optimization

Why Batch Makespan Is the Core Metric for Agent Workflows

Agent task execution is not continuous token generation, but a loop of "reason—act—observe." A sample may first call the model to plan the next step, then execute an action in the environment, receive feedback, and reason again. When a batch of such tasks runs in parallel, the total completion time doesn't depend on the average duration—it's dragged down by the slowest chain.

The research team explicitly sets the optimization goal as batch makespan—the total time required to complete all tasks in a batch. This metric is closer to the actual development experience than throughput: evaluations can't produce scores until the entire batch finishes, synthetic data can't proceed to the next round until the batch ends, and RL rollout is directly constrained by the slowest trajectory. Shortening the tail means shortening the entire development cycle.

Makespan is a classic metric in scheduling theory, referring to the total time elapsed from when a task set begins execution until all tasks are complete, determined by the latest-finishing task chain rather than the average or sum of individual task durations. Its counterpart, throughput, measures the number of tasks completed per unit time. In steady-state scenarios with continuously arriving tasks, high throughput often implies low makespan; but in scenarios with finite batches and large variance in task duration, the two can diverge significantly—a system can maintain high average throughput yet have the entire batch's waiting time extended by a few long-tail tasks that won't finish. Agent tasks fall precisely into the latter category: large variance in individual trajectory lengths and unpredictable environment waits mean makespan better reflects the real developer experience of "waiting for the whole batch to produce results."

Memory Allocation for Hybrid Models: The Trade-off Between KV Cache and Recurrent State

For hybrid-architecture LLMs (containing both attention layers and recurrent layers), memory must be allocated between KV cache and recurrent state. Improper allocation incurs two costs: too small a KV cache limits concurrency, while insufficient recurrent state triggers recomputation.

The paper proposes using a workload-based resource model to guide this allocation and provides a reference sample concurrency level—one that leverages parallelism while keeping recomputation within acceptable bounds. The idea here is not to pursue a single-point optimum, but to match the memory budget with actual sample concurrency requirements, avoiding hidden waits caused by resource misallocation.

KV cache stores the key-value vectors of historical tokens during autoregressive decoding in self-attention layers, avoiding redundant computation at each step; its memory footprint grows linearly with the number of concurrent sequences and context length. Recurrent state refers to the fixed-size hidden state maintained per sequence by recurrent layers in hybrid architectures (such as linear attention, state space models, or Mamba-like structures); it does not grow with context length, but each concurrent sample must hold its own copy. The two types of cache grow differently: KV cache scales with context length, while recurrent state scales with concurrency. If KV cache is under-allocated, concurrency must be reduced or frequent swapping occurs; if recurrent state space is insufficient, long sequences must be recomputed from scratch upon resumption—i.e., recomputation. Understanding this trade-off is the prerequisite for grasping the paper's resource model.

Trajectory-Aware Routing and Scheduling

Agent tasks inherently have trajectory structure: similar initial tasks tend to follow similar environment paths. The research team exploits this for trajectory-aware routing and scheduling—on one hand promoting cache reuse so that identical or similar reasoning prefixes hit existing caches; on the other hand balancing load across workers to prevent individual workers from becoming long tails.

Cache reuse and load balancing often conflict in traditional scheduling—placing similar tasks on the same worker benefits caching but may create hotspots. The trajectory-aware approach uses trajectory information to constrain both objectives simultaneously, striking a compromise between reuse rate and balance.

Prefix caching is a common optimization in modern inference engines: if multiple requests share the same leading token sequence, the system can directly reuse the already-computed KV cache, skipping redundant prefill computation. In Agent batch tasks, trajectories derived from the same initial task often share system prompts, tool definitions, and early reasoning prefixes, so cache hit rates can be substantial. However, caches are worker-local or local, and routing similar tasks to the same worker improves hit rates but easily overloads that worker, creating hotspots. The essence of trajectory-aware routing is joint optimization between "affinity" and "balance," typically grouping by trajectory fingerprints or similarity measures, then dynamically adjusting based on real-time load signals such as queue length.

CAAS Scheduling Under Constrained Environment Capacity

When environment-side capacity is limited, the bottleneck shifts from inference to environment execution. The research team decouples sample admission from environment execution and proposes Chain-Advancing Action Scheduling (CAAS). The core of CAAS is prioritizing long chains—using observed progress to identify which trajectories are most likely to become the batch tail and directing resources toward them, thereby shortening overall makespan.

This is a counterintuitive but reasonable strategy: conventional scheduling tends to process short tasks first to quickly drain the queue, but since makespan is determined by the slowest, prioritizing long chains is what truly compresses the tail.

Admission control refers to the policy determining which samples can enter the execution phase; decoupled from actual environment execution capacity, the system can first admit samples into a queue and then release them according to capacity, avoiding overall jitter caused by environment overload. Chain-Advancing in CAAS emphasizes estimating remaining length based on the number of steps or stages a trajectory has already advanced, giving limited environment slots preferentially to long chains most likely to become the batch tail. This contrasts with the classic Shortest Job First (SJF) strategy: SJF minimizes average completion time but may indefinitely postpone long tasks; makespan-oriented scheduling, by contrast, must actively favor long tasks. The two serve different objectives, and the paper's choice stems from its optimization target being total batch completion time rather than average waiting time.

Experimental Validation: Consistent Makespan Reduction Across Benchmarks

The study conducted online evaluations on four benchmarks—BFCL, SWE-bench Multilingual, WideSearch, and MCP-Atlas—using Ling-3.0-Flash and Ling-3.1-Flash, achieving makespan reductions of 10.4% to 65.0% while keeping evaluation scores aligned—meaning the speedup comes without sacrificing task quality.

The paper also introduces a Controlled replay mechanism that combines real inference with recorded environment responses and latencies, used for ablation analysis of individual optimizations. This approach is particularly practical in scenarios where environment interactions are difficult to reproduce stably. These methods have been applied to the training and evaluation pipelines of the Ling-3.x series models, actually accelerating the model development cycle.

Implications for Agent Engineering Practice

This work sends a clear signal: performance optimization for Agent workflows cannot focus solely on the inference engine. Joint optimization between the inference side and the environment side—memory allocation, cache routing, admission scheduling—is where the main room for compressing batch makespan lies. For teams building evaluation pipelines or RL training frameworks, tail scheduling and cache reuse are directions worth prioritizing.

One-line Summary

Ant Group's Ling team proposes joint inference-environment optimization that reduces Agent batch task makespan by 10.4%–65.0%.

Paragraph Summary

Addressing the efficiency bottleneck caused by the "reason—act—observe" loop in LLM Agent batch tasks, Ant Group's Ling team proposes a joint inference-environment optimization approach centered on batch makespan (total batch completion time). The method covers three aspects: using a workload resource model to guide KV cache and recurrent state memory allocation for hybrid-architecture LLMs to reduce recomputation; exploiting trajectory structure for aware routing and scheduling that balances prefix cache reuse with worker load balancing; and introducing CAAS scheduling under constrained environment capacity to prioritize long chains and compress the batch tail. On four benchmarks—BFCL, SWE-bench Multilingual, WideSearch, and MCP-Atlas—makespan is reduced by 10.4% to 65.0% with evaluation scores kept aligned, and the methods have been applied to the training and evaluation pipelines of the Ling-3.x series models.

#LLM Agent#batch makespan#inference-environment optimization#KV cache#prefix caching#CAAS scheduling#BFCL#SWE-bench#Ling model
Share:

Related articles