Manuscript Offprint
arXiv:2608.24004AgentSpec: Speculative Decoding for Batch Inference of LLM Agents
Abstract
Large language model (LLM)-based agent applications often incur high response time. Speculative decoding is a promising solution to improve the inference efficiency of LLM agents without impacting generation quality. However, existing speculative decoding algorithms exhibit substantial speed degradation as batch sizes grow, limiting their practicality to deploy in real-world agent applications. In this work, we first present a systematic analysis of speculative decoding for LLM agents and identify two dominant factors of speedup degradation: high rejection rate of speculative tokens, and under-utilization of dynamic token budgets. Motivated by these findings, we propose AgentSpec, a speculative decoding algorithm that addresses the limitations of existing methods for LLM agents. AgentSpec incorporates structure-isolated drafting that constrains speculation to semantically coherent segments of the agent workflow, reducing the drafts of irrelevant semantic paths and achieving an extremely low rejection rate. Moreover, AgentSpec adopts redundancy-aware budget allocation that exploits agent-level information to better utilize the dynamically-free token budget during the agent inference. We implement and evaluate AgentSpec on five different workloads and four different models from four different LLM families in vLLM. Our results demonstrate the superiority of AgentSpec over state-of-the-art.
1 Introduction
Large language model (LLM)-based agent applications have emerged as a powerful paradigm for solving complex tasks that require multi-step reasoning, tool invocation, and environment interaction (Li, 2025; Luo et al., 2025). However, in practical deployments, serving LLM agents often incurs high inference cost due to its long and multi-round generation (Wan et al., 2024; Wang et al., 2024; Luo et al., 2025; Wang et al., 2025), motivating the need for efficient methods for LLM agents.
Speculative decoding is a promising technique to reduce response time for LLM agents without impacting the generation quality (Xia et al., 2024). Previous works have shown notable speedups under small batch sizes (Li et al., 2025; Saxena, 2023; Oliaro et al., 2025; Miao et al., 2023; Huang et al., 2026). However, modern LLM serving systems (Kwon et al., 2023; Zheng et al., 2024) typically operate with large batch sizes to maximize hardware utilization, where state-of-the-art speculative decoding algorithms suffer substantial speed degradation, limiting their effectiveness for real-world agent applications.
To further understand such limitation, we conduct a systematic analysis of speculative decoding for LLM agents and conclude two dominant efficiency bottlenecks: ① High rejection rate of speculative tokens: Existing speculative decoding algorithms (Li et al., 2025; Saxena, 2023; Oliaro et al., 2025) incur a high rejection rate when applied to LLM agent workloads, resulting in substantial verification overhead for rejected tokens. As batch size increases, such overhead grows rapidly and can quickly outweigh the time saved by accepted tokens, leading to severe speedup degradation. ② Under-utilization of dynamic token budgets: The amount of token budget that can be used for speculation varies dynamically across requests and batches. However, existing approaches allocate speculative budgets either uniformly (Miao et al., 2023; Wu et al., 2025; Sadhukhan et al., 2025) or in a coarse-grained manner (Huang et al., 2026), leading to inefficient use of available token budgets and limited speedup for agentic workloads.
In this paper, we propose AgentSpec, a new speculative decoding algorithm that addresses the limitations of existing methods for LLM agents from prior approaches in two key aspects. ① Structure-isolated drafting: AgentSpec constrains speculation to semantically coherent segments of the agent workflow. By avoiding speculation across heterogeneous execution stages, AgentSpec reduces the generation of irrelevant speculative paths and achieves a substantially lower rejection rate. ② Redundancy-aware budget allocation: AgentSpec introduces a redundancy metric to guide the allocation of dynamically available token budgets across requests, improving overall inference efficiency for LLM agents under various batch sizes.
We implement AgentSpec in vLLM and compare it with four speculative decoding methods, including
Work was done during internship at Microsoft Research.
NGram, EAGLE-3, SuffixDecoding as well as state-of-the-art method MTP. To demonstrate the generability of AgentSpec, we conduct our evaluation on 4 models from four different LLM families (Qwen, DeepSeek, GPT-OSS, and MiMo) and on 4 different agentic workloads, including 2 workflow-based (Code Generation and Deep Research) and 2 model-based (SWE-Bench and GAIA). We highlight five of our findings: (1) AgentSpec consistently outperforms EAGLE-3, NGram and SuffixDecoding across all 4 agentic benchmarks and 4 different LLM families. (2) All existing speculative decoding algorithms suffer from severe speedup degradation for batch inference on agent workload and even become slower than normal autoregressive decoding. However, AgentSpec consistently achieves faster generation than autoregressive decoding, with at most speedup. (3) AgentSpec is also able to accelerate the batch inference on non-agentic workloads. Specifically, AgentSpec achieves speedup on Spec-Bench dataset with at most speed acceleration on its subset. (4) Moreover, AgentSpec even achieves a higher speedup compared with Multi-Token Prediction (MTP) on MiMo-7B. (5) Lastly, AgentSpec ensures a robust efficiency under various maximum batch size and even achieves a better speedup with none thinking mode.
2.1 Efficiency Optimization for LLM Agents
Large language model (LLM) agents have emerged as a powerful paradigm for complex tasks involving multi-step reasoning, tool invocation, and environment interaction. Recent LLMs with great agentic ability such as Qwen-3 (Yang et al., 2025) and GPT-OSS (OpenAI, 2025), and representative agentic workflow such as ReAct (Yao et al., 2023) and Reflexion (Shinn et al., 2023) built on top of modern LLM serving engines enable agents to iteratively generate actions and process observations. While these systems demonstrate strong capabilities, their inference efficiency remains a major bottleneck due to iterative generation and repeated model invocation (Wang et al., 2025; Luo et al., 2025).
Several lines of work aim to improve the efficiency of LLM agent execution. Some approaches reduce the number of model calls by improving agent-level planning or action selection. For example, LEAP (Verma and Bharadwaj, 2025) employs look-ahead planning to avoid ineffective actions, while Efficient Agents (Wang et al., 2025) optimizes task decomposition and action selection to solve tasks with fewer execution steps. Others focus on caching or reusing intermediate results across agent steps. For instance, APC (Zhang et al., 2025) reuses high-level plans across semantically similar tasks to amortize planning overhead. While these methods significantly improve efficiency, they may also negatively impact generation quality.
2.2 Speculative Decoding
Speculative decoding is a lossless inference acceleration technique that reduces LLM decoding latency by speculatively generating multiple tokens and verifying them with the target model (Xia et al., 2024).
A common approach, adopted by EAGLE-3 (Li et al., 2025) and Multi-Token Prediction (MTP) (Xia et al., 2025; DeepSeek-AI, 2024), trains a lightweight draft model to propose speculative tokens. More recently, draft-model-free methods retrieve candidate tokens directly from generation history. For example, NGram (Saxena, 2023) and SuffixDecoding (Oliaro et al., 2025) construct draft continuations by matching n-gram or suffix patterns, eliminating draft inference overhead. However, these algorithm-level designs often suffer from high rejection rates, leading to a high verification cost and poor scalability in large batches. Another line of work studies system-level optimizations, such as dynamic batching and budget control (Miao et al., 2023; Huang et al., 2026; Liu et al., 2024). For example, SPIRe (Neelam et al., 2025) adapts speculative decoding based on online performance feedback, while AdaSpec (Huang et al., 2026) models speculative inefficiency to satisfy SLO constraints. MagicDec (Sadhukhan et al., 2025) shows that speculative decoding can improve throughput in the long-context scenario. Nevertheless, most of these methods either overlook batch-level acceptance variance or rely on global acceptance statistics, making them brittle to dynamic online workloads. Consequently, although existing methods achieve notable gains in small-batch settings, their effectiveness under large-batch inference, prevalent in modern LLM serving and agentic applications, remains insufficiently explored.
3 Speculative Decoding for Batch Inference of LLM Agents
In this section, we provide a systematic efficiency analysis of large-batch speculative decoding in the LLM agent scenario. We choose the Code Generation Agent implemented by Reflexion (Shinn et al., 2023) and tested on USACO dataset (Shi et al., 2024) as the agent workload for analysis. To ensure a fair and realistic analysis, we deploy the LLM of the agent application in vLLM (Kwon et al., 2023), one of the production-ready LLM serving engines and select two representative speculative decoding algorithms that cover two main types as mentioned in Section 2.2, including the draft-model-based method EAGLE-3 (Li et al., 2025) and the draft-model-free method NGram (Saxena, 2023). Following the standard of previous work (Kwon et al., 2023), we choose the total token number generated divided by the total execution time of the workload as the throughput metric for efficiency evaluation.
3.1 Overall Efficiency Analysis
We first compare the throughput speedup of two representative speculative decoding methods for code gener-

Figure 1: Speedup in terms of Goodput (number of generated tokens divided by the execution time) (Liu et al., 2024) under various maximum batch size in vLLM for different speculative decoding algorithms on USACO dataset with Code Generation Agent implemented by Reflexion agentic workflow on Qwen-3-8B.
ation agents under varying maximum batch sizes in the vLLM engine. The results are shown in Figure 1. When the maximum batch size is 1, EAGLE-3 achieves over speedup and SuffixDecoding achieves over speedup, consistent with consensus that speculative decoding is effective under small batch sizes. However, as the batch size increases, the speedup rapidly diminishes. When the maximum batch size exceeds 32, speculative decoding even becomes slower than standard autoregressive decoding, indicating that existing speculative decoding methods scale poorly to large-batch agent serving scenarios.
To understand the cause of this degradation, we model the per-step execution time saving of speculative decoding with batch size as:
where denotes the number of drafted tokens in the current step, is the rejection rate that is defined as the ratio of rejected tokens to proposed tokens for each request in the batch, is the per-token time saved by accepting a draft token, and and are the per-token draft and verification costs.
Since is small and can be ignored, this formulation highlights two key factors that impact the efficiency: the rejection rate and , which we call the utilization of the draft token budget. In general lower rejection rates and higher budget utilization bring in an ideal speculative decoding with larger speedups.
3.2 Bottleneck Analysis
Motivated by the analysis above, we next examine how existing methods behave with respect to the rejection rate and the token budget utilization.
Bottleneck of High Rejection Rate. We record the rejection rate, defined as the ratio of rejected tokens to proposed tokens for each request in the batch from vLLM logs during Code Generation Agent inference. Table 1 records the average rejection rate for different speculative decoding algorithms. As shown, existing Table 1: Average per-request rejection rate ( ), defined as number of rejected tokens divided by number of draft tokens, for different speculative decoding algorithms on Reflexion agentic workflow.
| METRIC | EAGLE-3 | NGram | SuffixDecoding | AgentSpec |
|---|---|---|---|---|
| Rejection Rate | 53.3% | 88.7% | 65.9% | 26.4% (↓ 50%) |

Figure 2: Execution time comparison for FFN and Attention modules of Qwen-3-8B under various batch size.
speculative decoding methods suffer from extremely high rejection rates: EAGLE-3 exceeds 50%, while NGram exceeds 85% across most batch sizes. Such high rejection rates substantially limit the effective utilization of the draft token budget, directly contributing to the observed degradation in throughput speedup under large-batch settings for LLM agent inference.
Bottleneck of Token Budget Under-Utilization. We define the available token budget under batch size as , where denotes the arithmetic intensity of the deployed hardware for the LLM agent. This definition reflects the fact that, as the batch size increases, LLM inference—particularly the FFN layers—quickly becomes compute-bound and dominates end-to-end latency. As a result, the verification cost increases and eventually approaches the per-token acceptance saving , making the total execution time saving become:
To further illustrate this effect, we measure the per-layer decoding time of the FFN and attention modules of Qwen-3-8B using vLLM with FlashAttention-2 on an A100 GPU. The results are shown in Figure 2. When the batch size exceeds 256, which matches the arithmetic intensity of the A100, the FFN latency grows linearly with batch size and quickly dominates the total decoding time. In this regime, decoding becomes compute-bound by the FFN, and the per-token verification cost approaches the per-token autoregressive decoding cost . As a result, the time saved by accepting one draft token is almost entirely offset by the cost of verifying it, leaving speculative decoding with little or no performance gain. This observation justifies our definition of the available token budget , which captures the diminishing headroom for speculative tokens as batch size increases.
We next record the total number of draft tokens generated per decoding step under different batch sizes and

Figure 3: Comparison between maximum token budget and average proposed token number for batch inference of speculative decoding on Reflexion workflow.
compare it with the available token budget . For a fair comparison, we also implement the budget allocation strategy from AdaSpec (Huang et al., 2026), which assigns draft tokens based on per-request acceptance rates. As shown in Figure 3, we have two key findings. (1) Existing speculative decoding methods severely under-utilize the available token budget, with the actual draft token count remaining far below or over across all batch sizes. (2) Existing allocation strategy fails to improve budget utilization, indicating that acceptance-rate-based budgeting is ineffective to improve the batch inference of speculative decoding for LLM agent.
4 Method: AgentSpec

Figure 4: Overview of AgentSpec.
The overview of AgentSpec is provided in Figure 4. At a high level, AgentSpec is a model-free speculative decoding algorithm designed for LLM agents. It requires the agent application to provide an agentic structure identifier alongside the input prompt to the LLM server, which enables the system to organize and retrieve historical context according to agent-specific execution structure. During speculative drafting, AgentSpec retrieves draft candidates only from historical segments that belong to the same semantic group, thereby avoiding speculation across structurally mismatched contexts. Before verification, AgentSpec computes an integrated redundancy value for each request in the batch by combining local draft information with global generation history. It then allocates speculative token budgets across requests according to their relative redundancy scores and adjusts the draft length of each request accordingly. In the following, we describe the two key

Figure 5: Repeated token ratio under different minimum repeated span lengths . The repeated ratio is defined as the total length of maximal repeated segments with at least consecutive tokens appearing in historical generations, normalized by the total generation length. Repetitions are categorized by whether they occur under the same or different user queries and within the same or different semantic blocks.
components of AgentSpec —structure-isolated drafting and redundancy-aware budget allocation—in detail.
4.1 Structure-Isolated Drafting
Motivation: A key distinction between LLM agent applications and standard LLM workloads is that a single user query often spans multiple requests associated with different semantic blocks (e.g., reasoning, tool execution, and result interpretation). While generation patterns are highly consistent within the same semantic block, transitions across blocks or queries introduce substantial semantic shifts.
To quantify this effect, we analyze generation trajectories of Qwen-3-8B on the USACO dataset using a Reflexion-based code generation agent. For each request, we measure repeated token segments that reappear in previously generated content, distinguishing repetitions within the same block from those across different blocks or queries. A repetition is counted only if it contains at least k consecutive tokens, with overlapping matches merged into their longest contiguous span. As shown in Figure 5, repeated token segments overwhelmingly occur within the same semantic block of a single query, whereas cross-block and cross-query repetitions are rare. This observation indicates that speculative drafting can be substantially improved by being aware of semantic block boundaries and query scope, thereby reducing unnecessary drafting and speculative rejections. In contrast, existing methods such as NGram and SuffixDecoding retrieve draft candidates from global generation history without such distinctions, leading to high rejection rates and wasted verification cost in agentic workloads.
Key Design: The pseudocode of structured-isolated draft of AgentSpec is provided in Algorithm 1. As shown, the algorithm requires the agent application to explicitly provide semantic structure identifier together with each generation request as below:
where denotes the agent application identifier, denotes the user query index that triggers the current request, and represents the list of semantic blocks , defined by pairs of start and end string tags identified from previous generation history.
Mapping string-level semantic blocks to token-level generation is challenging due to subword tokenization, where token boundaries do not align with string boundaries. Direct token–string conversion during decoding is prohibitively expensive in common serving engines such as vLLM and sglang, where tokenization and decoding are handled by separate components.
To address this, AgentSpec adopts a design similar to XGrammar (Dong et al., 2025) by maintaining a cached token-to-string mapping M, enabling efficient online conversion of generated tokens without invoking the tokenizer. Based on this mapping, AgentSpec maintains a lightweight string-based pushdown automaton (PDA) P on the server, which is incrementally updated to track the current semantic block.
For each request , newly generated tokens are converted using and fed into the corresponding PDA to identify the active semantic block . AgentSpec maintains a separate structure-isolated cache for each semantic block and retrieves speculative drafts exclusively from the matched block, avoiding semantically irrelevant contexts and substantially reducing speculative rejections. As shown in Table 1, AgentSpec achieves a rejection rate as low as 26%, over lower than existing baselines.
4.2 Redundancy-aware Budget Allocation
Motivation: The pseudocode of the redundancy-aware budget allocation is shown in Algorithm 2. To efficiently utilize the dynamic token budget in speculative decoding, more draft tokens should be assigned to requests with higher acceptance potential. Over-allocating tokens to low-acceptance requests wastes verification cost, while overly conservative allocation under-utilizes the available budget. The key challenge is thus to identify a reliable request-level signal that predicts draft acceptance. In agent workloads, requests exhibit varying degrees of redundancy in their generation history. Intuitively, drafts aligned with repeated historical patterns are more likely to be accepted. To validate this intuition, we analyze generation traces from Qwen-3-8B on Code Generation Agent and measure draft redundancy as the fraction of matched historical continuations that fully accept the draft. As shown in Figure 6, higher redundancy strongly correlates with higher acceptance rates, with the correlation strengthening as more matched continuations are observed.
Key Design: To estimate the acceptance likelihood of a speculative draft for each request, AgentSpec introduces a redundancy score g:

Figure 6: Acceptance ratio under different redundancy ratio with different matching pattern length.
where n is the number of candidate continuations retrieved from the generation history under the same semantic block and user query, and c is the number of continuations agreeing on the most frequent prefix. The ratio c/n captures the consensus among candidates, while the saturation term downweights unreliable estimates when historical support is limited. The hyperparameter controls the minimum confidence under low-support scenarios.
Given the redundancy scores, AgentSpec computes the batch-level speculative token budget as
where is the batch size and controls the overall speculative budget. For each request , AgentSpec retrieves candidate drafts within the same semantic block and query, identifies the most frequent continuation prefix , and computes its redundancy score . The per-request draft length is then allocated as
prioritizing requests with higher redundancy while ensuring that each request can draft at least its most confident prefix.
As shown in Figure 3, AgentSpec consistently keeps the total number of drafted tokens below the maximum budget and approaches it as batch size increases, indicating effective utilization of the available speculative budget.
5 Experiments
5.1 Experimental Setups
Baselines. We compare AgentSpec against two groups of methods: (1) Draft-model-based speculative decoding methods: EAGLE-3 (Li et al., 2025) and MTP (Xia et al., 2025). (2) Draft-model-free speculative decoding methods: NGram (Saxena, 2023) and SuffixDecoding (Oliaro et al., 2025). All baselines are evaluated under identical serving configurations to ensure a fair comparison.
Models and Datasets. To demonstrate the generality of AgentSpec, we evaluate its performance on four models from different families, including Qwen-3-8B (Yang et al., 2025), GPT-OSS-20B (OpenAI, 2025),
Table 2: Goodput (tokens/sec) of AgentSpec and baselines on four different agentic workloads with three different models. The best performance is marked in bold. The speedup is measured by comparing the goodput with the normal autoregressive decoding. The relative performance gain compared to the best-performing baseline is marked in green inside bracket.
| MODEL | METHOD | Deep Research Agent | Code Generation Agent | GAIA | SWE-Bench | ||||
|---|---|---|---|---|---|---|---|---|---|
| Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | ||
| Qwen-3-8B | Normal | 617.41 | × 1.00 | 636.09 | × 1.00 | 501.27 | × 1.00 | 652.44 | × 1.00 |
| EAGLE-3 | 605.14 | × 0.98 | 539.01 | × 0.85 | 468.22 | × 0.93 | 523.12 | × 0.80 | |
| NGram | 509.62 | × 0.83 | 422.58 | × 0.66 | 308.27 | × 0.61 | 408.28 | × 0.63 | |
| SuffixDecoding | 598.74 | × 0.97 | 579.21 | × 0.91 | 498.16 | × 0.99 | 556.64 | × 0.85 | |
| AgentSpec | 661.43 (↑ 9%) | × 1.07 | 828.10 (↑ 43%) | × 1.30 | 537.78 (↑ 8%) | × 1.07 | 854.69 (↑ 42%) | × 1.31 | |
| GPT-OSS-20B | Normal | 201.43 | × 1.00 | 289.26 | × 1.00 | 247.67 | × 1.00 | 351.22 | × 1.00 |
| EAGLE-3 | 125.71 | × 0.62 | 161.34 | × 0.56 | 112.16 | × 0.45 | 198.81 | × 0.57 | |
| NGram | 158.91 | × 0.79 | 175.19 | × 0.61 | 109.22 | × 0.44 | 253.36 | × 0.72 | |
| SuffixDecoding | 196.54 | × 0.98 | 295.85 | × 1.02 | 187.79 | × 0.76 | 319.73 | × 0.91 | |
| AgentSpec | 297.54 (↑ 51%) | × 1.48 | 584.43 (↑ 104%) | × 2.02 | 295.76 (↑ 57%) | × 1.19 | 595.20 (↑ 86%) | × 1.69 | |
| DSK-Distill-8B | Normal | 987.66 | × 1.00 | 1230.28 | × 1.00 | 823.39 | × 1.00 | 1432.27 | × 1.00 |
| EAGLE-3 | 965.43 | × 0.98 | 1119.29 | × 0.91 | 864.43 | × 1.05 | 1098.82 | × 0.77 | |
| NGram | 752.66 | × 0.76 | 797.18 | × 0.65 | 725.29 | × 0.88 | 1014.47 | × 0.71 | |
| SuffixDecoding | 995.14 | × 1.01 | 1041.29 | × 0.85 | 820.09 | × 1.00 | 1498.69 | × 1.05 | |
| AgentSpec | 1294.65 (↑ 30%) | × 1.31 | 1671.34 (↑ 49%) | × 1.36 | 924.47 (↑ 7%) | × 1.12 | 2281.87 (↑ 52%) | × 1.59 | |

(a) Qwen-3-8B
(b) GPT-OSS-20B
(c) DSK-8B
Figure 7: Speedup in terms of Goodput (token/s) for AgentSpec and baselines compared with normal autoregressive decoding on all subsets in USACO dataset with Code Generation Agent implemented by Reflexion agentic workflow on three different models.
Deepseek-R1-Distill-Llama-8B (DeepSeek-AI, 2025), and MiMo-7B (Xia et al., 2025). We evaluate on four most popular agentic workloads covering two main types. The first is workflow-based agent workload, including Code Generation that is implemented with Reflexion framework (Shinn et al., 2023) and tested on USACO benchmark (Shi et al., 2024) with multiple difficulty subsets (Bronze, Silver, Gold, and Platinum), and Deep Research that is implemented with LangChain DeepResearch framework (Team, 2026) and tested on DeepResearch-Bench benchmark (Du et al., 2025) with three different levels of tasks that require long-horizon reasoning and document synthesis. The second is model-based agentic workloads, including SWE-Bench-Lite (Jimenez et al., 2024) and GAIA (Mialon et al., 2024) on OpenHands platform (Wang et al., 2025). Finally, we evaluate AgentSpec on SpecBench (Xia et al., 2024) to test its performance enhancement on non-agentic data.
Metrics. Following the standards of Turbospec (Liu et al., 2024), we use goodput, defined as the total number of generated tokens divided by the execution time of the entire agent workload, as the main metric to evaluate the goodput of AgentSpec and its baseline methods. We also report speedup in terms of goodput for a clearer comparison, as well as latency (Luo et al., 2025), which is defined as the end-to-end execution time from when a user query enters the agent environment to when the final response is returned.
Implementation Details. To ensure a fair and realistic comparison, we implemented AgentSpec and evaluate its performance with baseline methods in vLLM (Kwon et al., 2023), a production-style LLM serving engine. All other baseline methods are also evaluated with the official implementation provided in vLLM under maximum batch size 256. The detailed configurations in vLLM for running the evaluation is provided in Section A.1.
5.2 End-to-End Comparison
We first compare the end-to-end efficiency of AgentSpec against existing baseline methods on two agent applications—Deep Research Agent and Code Generation Agent—as well as two agent benchmarks, GAIA and SWE-Bench, across three different LLMs: Qwen-3-8B, GPT-OSS-20B, and DeepSeek-Distill-LLaMA-8B. The results are shown in Table 2. AgentSpec consistently outperforms all baseline spec-ulative decoding methods in terms of efficiency, achieving up to 104% higher goodput. Notably, the goodput of most baseline methods is even lower than that of standard autoregressive decoding, indicating limited benefits in agent workloads. In contrast, AgentSpec consistently delivers improved goodput across all agent workloads and model settings, attaining up to a speedup over autoregressive decoding.
5.3 Comparison with Different Execution Patterns
Even within the same agent workload, problem difficulty can lead to distinct agent execution patterns. A common phenomenon is that more challenging problems induce longer contexts and a larger number of generation steps, as the agent needs to issue more LLM requests to complete the task. To demonstrate the generality of AgentSpec, we evaluate its efficiency using the Code Generation Agent across all subsets of the USACO dataset, with difficulty levels ranging from Bronze to Platinum. As shown in Figure 7, AgentSpec consistently achieves better speedup than other speculative decoding methods across all difficulty subsets and LLMs. More importantly, AgentSpec also consistently outperforms standard autoregressive decoding, achieving up to a speedup on the USACO subsets.
5.4 Comparison on Non-Agentic Benchmark
Following the experimental protocol of (Oliaro et al., 2025), we conduct the evaluation on a non-agentic benchmark Spec-Bench (Xia et al., 2024) using Qwen-3-8B. Unlike agentic workloads, which often involve multi-turn requests for a single query and contain explicit semantic structures, Spec-Bench contains fewer repeated historical generations, making it more challenging to utilize history information for drafting. However, as shown in Table 4, AgentSpec still consistently achieves higher efficiency than both speculative decoding baselines and standard autoregressive decoding across all subsets as well as the full Spec-Bench benchmark.
5.5 Comparison with Multi-Token Prediction
Multi-Token Prediction (MTP) is a recent speculative decoding paradigm that jointly trains an MTP module as the draft model during the pre-training stage of the target model. To further demonstrate the effectiveness of AgentSpec, we compare its efficiency with MTP speculative decoding method using MiMo-7B on the Code Generation Agent over the USACO dataset. As shown in Table 3, MTP exhibits limited efficiency gains under batched LLM agent inference. In contrast, AgentSpec consistently achieves higher efficiency than MTP and maintains a clear speedup over standard autoregressive decoding on MiMo-7B.
5.6 Latency Analysis
Tailed Latency. We further analyze the end-to-end program latency, defined as the time elapsed from when a user query is submitted to the agent application to

Figure 8: Tailed latency analysis for AgentSpec and baselines on Code Gen agentic workflow.
when the final output is returned. The CDF of the tail latency is shown in Figure 8. AgentSpec consistently achieves lower latency than baseline speculative decoding methods, and reduces tail latency by up to and compared to standard autoregressive decoding at the P90 and P99 percentiles, respectively.
Execution Breakdown Analysis. We have performed fine-grained analysis including both drafting and verification costs on Reflexion Agentic Workflow. The results in Table 5 show that AgentSpec significantly reduces verification overhead compared to baselines, which is the dominant factor in overall speedup. AgentSpec incurs slightly higher drafting overhead than NGram and SuffixDecoding. This additional cost mainly stems from maintaining the PDA in the structure-isolated drafting component and computing redundancy statistics in the redundancy-aware budget allocation module. Nevertheless, the overhead remains negligible, amounting to less than 2 ms, and the overall drafting cost of AgentSpec is still lower than all baseline methods.
5.7 Ablation Studies
Modular Sensitivity Study. We evaluate the separate contributions of the two key components (i.e., structure-isolated drafting and redundancy-aware budget allocation) of AgentSpec. Let AgentSpec (S) denote the version of AgentSpec with structure-isolated drafting only; AgentSpec (R) denote the version of AgentSpec with SuffixDecoding and redundancy-aware budget allocation. As shown in Table 6, we have three observations. (1) AgentSpec (S), AgentSpec (R) and AgentSpec consistently outperform existing speculative decoding methods. (2) AgentSpec consistently outperforms both AgentSpec (S) and AgentSpec (R). This result demonstrates the unique contribution from each of the two key components and the importance of combining both components to achieve the best performance. (3) Comparing between AgentSpec (S) and AgentSpec (R), AgentSpec (S) achieves a higher speedup compared to AgentSpec (R), indicating that structure-isolated drafting plays a more significant role than redundancy-aware budget allocation. Performance without Explicit Semantic Structures. Since the structure-isolated drafting component of AgentSpec requires the agent application to provide explicit semantic block boundaries, some real-world
Table 3: Goodput (tokens/sec) of AgentSpec and baselines, including MTP, on MiMo-7B. The best performance is marked in bold. The speedup is measured by comparing the goodput with the normal autoregressive decoding. The relative performance gain compared to the best-performing baseline is marked in green inside bracket.
| MODEL | METHOD | Code Gen.(Bronze) | Code Gen.(Silver) | Code Gen.(Gold) | Code Gen.(Platinum) | Code Gen.(All) | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | ||
| MiMo-7B | Normal | 2768.67 | ×1.00 | 3093.50 | ×1.00 | 2532.30 | ×1.00 | 1141.64 | ×1.00 | 2572.16 | ×1.00 |
| NGram | 1322.92 | ×0.48 | 1399.76 | ×0.45 | 1383.92 | ×0.55 | 990.87 | ×0.87 | 1306.92 | ×0.51 | |
| SuffixDecoding | 1609.41 | ×0.58 | 1624.98 | ×0.53 | 1599.63 | ×0.63 | 1235.12 | ×1.08 | 1653.26 | ×0.64 | |
| MTP | 1924.46 | ×0.70 | 2001.28 | ×0.65 | 2034.30 | ×0.80 | 1349.10 | ×1.18 | 1875.18 | ×0.73 | |
| AgentSpec | 3324.71 (↑73%) | ×1.20 | 3751.44 (↑87%) | ×1.21 | 2925.40 (↑44%) | ×1.16 | 1527.14 (↑13%) | ×1.34 | 3318.99 (↑77%) | ×1.29 | |
Table 4: Goodput (tokens/sec) of AgentSpec and baselines on Spec-Bench on Qwen-3-8B. The best performance is marked in bold. The speedup is measured by comparing the goodput with the normal autoregressive decoding.
| MODEL | METHOD | MT Conversation | Question Answering | Summarization | Translation | Math Reasoning | Retrieval Augmented | All | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | Tokens/s | Speedup | ||
| Qwen-3-8B | Normal | 939.50 | ×1.00 | 860.97 | ×1.00 | 1277.50 | ×1.00 | 2013.02 | ×1.00 | 1064.78 | ×1.00 | 191.60 | ×1.00 | 697.42 | ×1.00 |
| EAGLE-3 | 1005.63 | ×1.07 | 895.25 | ×1.04 | 1552.62 | ×1.22 | 2319.01 | ×1.15 | 1045.28 | ×0.98 | 168.21 | ×0.88 | 783.25 | ×1.12 | |
| NGram | 581.26 | ×0.62 | 351.28 | ×0.41 | 1082.57 | ×0.85 | 2166.37 | ×1.08 | 959.38 | ×0.90 | 263.11 | ×1.37 | 545.39 | ×0.78 | |
| SuffixDecoding | 1007.08 | ×1.07 | 873.12 | ×1.01 | 1213.63 | ×0.95 | 2141.79 | ×1.06 | 1121.48 | ×1.05 | 212.19 | ×1.10 | 712.79 | ×1.02 | |
| AgentSpec | 1128.09 | ×1.20 | 929.85 | ×1.08 | 1481.90 | ×1.16 | 2294.12 | ×1.14 | 1075.43 | ×1.01 | 267.14 | ×1.40 | 796.01 | ×1.14 | |
Table 5: Execution breakdown of AgentSpec and baselines on Code Gen agentic Workload. The best performance is marked in bold.
| TIME (MINUTES) | EAGLE-3 | NGram | SuffixDecoding | AgentSpec |
|---|---|---|---|---|
| Draft | 5.72 | 0.68 | 1.41 | 1.74 |
| Verification | 34.24 | 39.82 | 33.12 | 26.11 (↓ 21%) |
| Overall | 39.96 | 40.50 | 34.53 | 27.85 (↓ 19%) |
Table 6: Goodput of variants of AgentSpec and baselines on Deep Research Agent and Code Generation Agent workloads. The best performance is marked in bold. The speedup is measured by comparing the goodput with the normal autoregressive decoding.
| MODEL | METHOD | Deep Research Agent | Code Generation Agent | ||
|---|---|---|---|---|---|
| Tokens/s | Speedup | Tokens/s | Speedup | ||
| QWEN-3-8B | Normal | 617.41 | × 1.00 | 636.09 | × 1.00 |
| EAGLE-3 | 605.14 | × 0.98 | 539.01 | × 0.85 | |
| NGram | 509.62 | × 0.83 | 422.58 | × 0.66 | |
| SuffixDecoding | 598.74 | × 0.97 | 579.21 | × 0.91 | |
| AGENTSPEC (S) | 647.12 (↑ 9%) | × 1.05 | 795.54 (↑ 37%) | × 1.25 | |
| AGENTSPEC (R) | 623.33 (↑ 3%) | × 1.01 | 702.28 (↑ 21%) | × 1.10 | |
| AGENTSPEC (N) | 661.08 (↑ 10%) | × 1.07 | 809.12 (↑ 40%) | × 1.27 | |
| AGENTSPEC | 661.43 (↑ 10%) | × 1.07 | 828.10 (↑ 43%) | × 1.30 | |
agentic workloads may not expose such structure during generation. To assess the generality of AgentSpec, we have evaluated a variant that operates without semantic structure inputs, denoted as AgentSpec (N). As shown in Table 6, AgentSpec (N) consistently outperforms both speculative decoding baselines and standard autoregressive decoding.
Performance Under Various Maximum Batch Size. We next evaluate the performance of AgentSpec under different maximum batch size configurations in the vLLM engine. As shown in Figure 9(a), while some existing speculative decoding methods (e.g., SuffixDecoding) achieve higher efficiency than standard autoregressive decoding at small batch sizes, their speedup gradually degrades and can even fall below autoregres- sive decoding as the maximum batch size increases. In contrast, AgentSpec consistently maintains superior efficiency across all batch size configurations, outperforming both speculative decoding baselines and standard autoregressive decoding.

(a) Various Batch Size
(b) Various Thinking Mode
Figure 9: Speedup in terms of Goodput (tokens/sec) of AgentSpec and baselines on workload of code generation agent under various maximum batch size and different thinking modes.
Performance in Different Thinking Modes. Recent reasoning-oriented LLMs allow users to adjust thinking modes, which can substantially affect both the generated content and output length in agent applications. To study this effect, we evaluate AgentSpec on Qwen-3-8B under two thinking modes: w/ think and w/o think (Yang et al., 2025). As shown in Figure 9(b), AgentSpec consistently achieves superior performance across both modes. Notably, under the w/o think setting, AgentSpec is over faster than standard autoregressive decoding.
6 Conclusion
In this paper, we presented AgentSpec, a speculative decoding algorithm tailored for batch inference of LLM agents. AgentSpec introduces structure-isolated drafting to constrain speculation to semantically coherent segments of the agent workflow, achieving extremely low rejection rates. It also proposes redundancy-aware budget allocation to better exploit dynamically available token budgets using agent-level redundancy.
Our experimental results demonstrate the superiority of AgentSpec over state-of-the-art baselines.
Limitation
AgentSpec introduces a lightweight interface between the agent and serving system, which may require minor adaptation in practice. In addition, its structure-isolated drafting component benefits from explicit semantic block information. Although AgentSpec can operate without such metadata, its speedup may depend on the amount of repeated generation patterns available in the workload.
Ethical Considerations
AgentSpec is a serving-time acceleration method for LLM-based agents. It does not modify model parameters, training data, or the generation objective, and therefore is not intended to change the output distribution or content policy of the underlying model. Existing safety mechanisms for autoregressive decoding, such as content moderation, tool-use control, and deployment restrictions, should remain applicable when AgentSpec is enabled. Improving inference efficiency may reduce the cost of deploying LLM agents at scale, which can benefit practical applications but may also lower the barrier for misuse, such as automated spam generation or unsafe tool-use workflows. We therefore encourage responsible deployment with appropriate safeguards, including rate limiting, permission control, and monitoring. AgentSpec requires only lightweight semantic structure metadata from the agent application; such metadata should describe workflow structure rather than private or sensitive user information. Our experiments use publicly available benchmarks and do not require collecting additional private user data.
References
[1] DeepSeek-AI. 2024. Deepseek-v3 technical report. CoRR, abs/2412.19437.
[2] DeepSeek-AI. 2025. Deepseek-r1: Incentivizing reasoning capability in llms via reinforcement learning. CoRR, abs/2501.12948.
[3] Yixin Dong, Charlie F. Ruan, Yaxing Cai, Ziyi Xu, Yilong Zhao, Ruihang Lai, and Tianqi Chen. 2025. Xgrammar: Flexible and efficient structured generation engine for large language models. In MLSys. OpenReview.net/mlsys.org.
[4] Mingxuan Du, Benfeng Xu, Chiwei Zhu, Xiaorui Wang, and Zhendong Mao. 2025. Deepresearch bench: A comprehensive benchmark for deep research agents. CoRR, abs/2506.11763.
[5] Kaiyu Huang, Hao Wu, Zhubo Shi, Han Zou, Minchen Yu, and Qingjiang Shi. 2026. Adaspec: Adaptive speculative decoding for fast, slo-aware large language model serving. In Proceedings of the
2025 ACM Symposium on Cloud Computing, SoCC '25, page 361–374, New York, NY, USA. Association for Computing Machinery.
[6] Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, and Karthik R. Narasimhan. 2024. Swe-bench: Can language models resolve real-world github issues? In ICLR. OpenReview.net.
[7] Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph Gonzalez, Hao Zhang, and Ion Stoica. 2023. Efficient memory management for large language model serving with pagedattention. In SOSP, pages 611–626. ACM.
[8] Xinzhe Li. 2025. A review of prominent paradigms for llm-based agents: Tool use, planning (including rag), and feedback learning. In COLING, pages 9760–9779. Association for Computational Linguistics.
[9] Yuhui Li, Fangyun Wei, Chao Zhang, and Hongyang Zhang. 2025. EAGLE-3: scaling up inference acceleration of large language models via training-time test. CoRR, abs/2503.01840.
[10] Xiaoxuan Liu, Cade Daniel, Langxiang Hu, Woosuk Kwon, Zhuohan Li, Xiangxi Mo, Alvin Cheung, Zhijie Deng, Ion Stoica, and Hao Zhang. 2024. Optimizing speculative decoding for serving large language models using goodput. arXiv preprint arXiv:2406.14066.
[11] Junyu Luo, Weizhi Zhang, Ye Yuan, Yusheng Zhao, Junwei Yang, Yiyang Gu, Bohan Wu, Binqi Chen, Ziyue Qiao, Qingqing Long, Rongcheng Tu, Xiao Luo, Wei Ju, Zhiping Xiao, Yifan Wang, Meng Xiao, Chenwu Liu, Jingyang Yuan, Shichang Zhang, and 7 others. 2025. Large language model agent: A survey on methodology, applications and challenges. CoRR, abs/2503.21460.
[12] Michael Luo, Xiaoxiang Shi, Colin Cai, Tianjun Zhang, Justin Wong, Yichuan Wang, Chi Wang, Yanping Huang, Zhifeng Chen, Joseph E. Gonzalez, and Ion Stoica. 2025. Autelix: An efficient serving engine for LLM agents as general programs. CoRR, abs/2502.13965.
[13] Grégoire Mialon, Clémentine Fourrier, Thomas Wolf, Yann LeCun, and Thomas Scialom. 2024. GAIA: a benchmark for general AI assistants. In ICLR. OpenReview.net.
[14] Xupeng Miao, Gabriele Oliaro, Zhihao Zhang, Xinhao Cheng, Zeyu Wang, Rae Ying Yee Wong, Zhuoming Chen, Daiyaan Arfeen, Reyna Abhyankar, and Zhihao Jia. 2023. Specinfer: Accelerating generative LLM serving with speculative inference and token tree verification. CoRR, abs/2305.09781.
[15] Sanjit Neelam, Daniel Heinlein, Vaclav Cvicek, Akshay Mishra, and Reiner Pope. 2025. Spire: Boosting LLM inference throughput with speculative decoding. CoRR, abs/2504.06419.
[16] Gabriele Oliaro, Zhihao Jia, Daniel Campos, and Aurick Qiao. 2025. Suffixdecoding: Extreme speculative decoding for emerging ai applications. In The Thirty-ninth Annual Conference on Neural Information Processing Systems.
[17] OpenAI. 2025. gpt-oss-120b & gpt-oss-20b model card. CoRR, abs/2508.10925.
[18] Ranajoy Sadhukhan, Jian Chen, Zhuoming Chen, Vashisth Tiwari, Ruihang Lai, Jinyuan Shi, Ian EnHsu Yen, Avner May, Tianqi Chen, and Beidi Chen. 2025. Magicdec: Breaking the latency-throughput tradeoff for long context generation with speculative decoding. In ICLR. OpenReview.net.
[19] Apoorv Saxena. 2023. Prompt lookup decoding.
[20] Quan Shi, Michael Tang, Karthik Narasimhan, and Shunyu Yao. 2024. Can language models solve olympiad programming? CoRR, abs/2404.10952.
[21] Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, and Shunyu Yao. 2023. Reflexion: language agents with verbal reinforcement learning. In NeurIPS.
[22] Langchain Team. 2026. Langchain open deep research.
[23] Nikhil Verma and Manasa Bharadwaj. 2025. LEAP & LEAN: Look-ahead planning and agile navigation for LLM agents. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 6: Industry Track), pages 896–933, Vienna, Austria. Association for Computational Linguistics.
[24] Zhongwei Wan, Xin Wang, Che Liu, Samiul Alam, Yu Zheng, Jiachen Liu, Zhongnan Qu, Shen Yan, Yi Zhu, Quanlu Zhang, Mosharaf Chowdhury, and Mi Zhang. 2024. Efficient large language models: A survey. Trans. Mach. Learn. Res., 2024.
[25] Ningning Wang, Xavier Hu, Pai Liu, He Zhu, Yue Hou, Heyuan Huang, Shengyu Zhang, Jian Yang, Jiaheng Liu, Ge Zhang, Changwang Zhang, Jun Wang, Yuchen Eleanor Jiang, and Wangchunshu Zhou. 2025. Efficient agents: Building effective agents while reducing cost. CoRR, abs/2508.02694.
[26] Xin Wang, Zhongwei Wan, Arvin Hekmati, Mingyu Zong, Samiul Alam, Mi Zhang, and Bhaskar Krishnamachari. 2024. Iot in the era of generative ai: Vision and challenges. arXiv preprint arXiv:2401.01923.
[27] Xingyao Wang, Boxuan Li, Yufan Song, Frank F. Xu, Xiangru Tang, Mingchen Zhuge, Jiayi Pan, Yueqi Song, Bowen Li, Jaskirat Singh, Hoang H. Tran, Fuqiang Li, Ren Ma, Mingzhang Zheng, Bill Qian, Yanjun Shao, Niklas Muennighoff, Yizhe Zhang, Binyuan Hui, and 2 others. 2025. Openhands: An open platform for AI software developers as generalist agents. In ICLR. OpenReview.net.
[28] Zhaoxuan Wu, Zijian Zhou, Arun Verma, Alok Prakash, Daniela Rus, and Bryan Kian Hsiang Low.
- TETRIS: optimal draft token selection for batch speculative decoding. In ACL (1), pages 33329–33345. Association for Computational Linguistics.
[29] Bingquan Xia, Bowen Shen, Cici, Dawei Zhu, Di Zhang, Gang Wang, Hailin Zhang, Huaqiu Liu, Jiebao Xiao, Jinhao Dong, Liang Zhao, Peidian Li, Peng Wang, Shihua Yu, Shimao Chen, Weikun Wang, Wenhan Ma, Xiangwei Deng, Yi Huang, and 44 others. 2025. Mimo: Unlocking the reasoning potential of language model - from pretraining to posttraining. CoRR, abs/2505.07608.
[30] Heming Xia, Zhe Yang, Qingxiu Dong, Peiyi Wang, Yongqi Li, Tao Ge, Tianyu Liu, Wenjie Li, and Zhi-fang Sui. 2024. Unlocking efficiency in large language model inference: A comprehensive survey of speculative decoding. In ACL (Findings), pages 7655–7671. Association for Computational Linguistics.
[31] An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, Chujie Zheng, Dayiheng Liu, Fan Zhou, Fei Huang, Feng Hu, Hao Ge, Haoran Wei, Huan Lin, Jialong Tang, and 40 others. 2025. Qwen3 technical report. CoRR, abs/2505.09388.
[32] Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik R. Narasimhan, and Yuan Cao. 2023. React: Synergizing reasoning and acting in language models. In ICLR. OpenReview.net.
[33] Qizheng Zhang, Michael Wornow, and Kunle Olukotun. 2025. Agentic plan caching: Test-time memory for fast and cost-efficient LLM agents. In The Thirty-ninth Annual Conference on Neural Information Processing Systems.
[34] Lianmin Zheng, Liangsheng Yin, Zhiqiang Xie, Chuyue Sun, Jeff Huang, Cody Hao Yu, Shiyi Cao, Christos Kozyrakis, Ion Stoica, Joseph E. Gonzalez, Clark W. Barrett, and Ying Sheng. 2024. Sglang: Efficient execution of structured language model programs. In NeurIPS.
A Appendix.
A.1 Experiment Configuration Details
We implement AgentSpec and conduct all experiments using the vLLM v0.12.0 V1 engine. For a fair comparison, we directly run the official implementations of all baseline methods with their default configurations provided by vLLM. We run each experiment on NVIDIA A100 80G GPUs with fix the maximum batch size and serving parameters for all methods. Unless otherwise specified, all goodput and speedup numbers are averaged over five times measurements controlled with various seed numbers and under the default maximum batch size 256 in vLLM.
Specifically, for NGram, we set num-speculative-tokens to 5 and ngram-prompt-lookup-max to 4; for SuffixDecoding, we set num-speculative-tokens = 32.
We use FlashAttention-2 as the attention backend and adopt the default maximum batch size in vLLM (256). For MTP, we directly use the official MTP module provided by MiMo-7B-RL during inference.
For AgentSpec, the speculation length dynamically adapts to the ongoing batch size and therefore does not require any speculation-length hyperparameters at launch time. Instead, AgentSpec requires the agent application to provide high-level contextual information, including the agent's semantic structure and the query index of the current request.
Concretely, we extend the vLLM engine with three additional parameters—structure: string, query-id: int, and agent-id: int—which can be passed by the agent application at inference time. The structure field encodes the paired delimiters of semantic blocks (e.g., code blocks, tool calls, and mathematical expressions) used by AgentSpec for redundancy-aware speculation. An example API request is shown in Listing 1.
Listing 1: Example of API request command when using AgentSpec in vLLM
resp = await client.chat.completions. create( model="Qwen/Qwen3-8B", messages=[ {"role": "system", "content": "Respond in Korean."}, {"role": "user", "content": f"Say hi. (req {i})"}}, ], temperature=0.6, extra_body={ "query_id": 1, "agent_id": 1, # Code Structure and Math Structure "structure": "[ [("``python", "", ""), ("<tool_call>", "<\tool_call>"), ], [("[", ""]"), ("\", "")", (""), ("")] ] ] ]
] ",
)
Table 7: Speedup of AgentSpec on different GPU platforms on GPT-OSS-20B across agent workloads.
| Speedup | CodeGen | DeepResearch | SWE-Bench | GAIA |
|---|---|---|---|---|
| 1×A100 80G | 2.02× | 1.48× | 1.69× | 1.19× |
| 1×H100 80G | 2.28× | 1.67× | 1.92× | 1.54× |
A.2 Algorithm Pseudocode
Algorithm 1 shows the pseudocode of the first component of AgentSpec, Structure-Isolated Drafting. Algorithm 2 shows the pseudocode of the second component of AgentSpec, Redundancy-Aware Budget Allocation.
Algorithm 1 Structure-Isolated Drafting
1: Input: generation request , history cache , token-to-string map 2: Output: draft token candidates 3: Initialize PDA for request 4: 5: for each newly generated token in request do 6: Convert to string using cached map 7: Feed converted string incrementally into 8: Determine current semantic block using PDA state 9: end for 10: Retrieve structure-isolated cache 11: if is empty then 12: return 13: end if 14: for each historical continuation do 15: Extract candidate draft continuation from 16: 17: end for 18: return
A.3 Comparison On Various GPU Architectures
We evaluated AgentSpec on H100 GPU using GPT-OSS-20B. The results in Table 7 show that AgentSpec achieves even higher speedups compared to A100, indicating that our conclusions generalize across hardware generations. From a system perspective, our analysis depends primarily on two factors—rejection rate and token budget utilization—which are also not specific to a particular GPU architecture or serving engine.
A.4 Theoretical Complexity analysis
We then provide the time and space complexity analysis of AgentSpec and other baseline methods as follows.
Algorithm 2 Redundancy-Aware Budget Allocation
1: Input: batch of requests , draft candidate sets , hyperparameter ,
2: Output: per-request draft length
3: Compute total speculative budget
4: for each request in batch do
5: {number of candidate continuations}
6: if then
7:
8: continue
9: end if
10: Identify most frequent continuation prefix
11: number of continuations agreeing on
12:
13:
14: end for
15:
16: for each request in batch do
17:
18: end for
19: return
Regarding time complexity, for NGram/SuffixDecoding, drafting consists of constant-time lookup followed by candidate extension, with overall cost , where L is the draft length. AgentSpec preserves the same dominant cost. The additional components are lightweight: (a) PDA update: amortized per token, and (b) semantic filtering + redundancy scoring: per step. Thus, , which has the same asymptotic complexity as NGram with only a small constant-factor overhead. Regarding space complexity (CPU/DRAM), NGram requires memory to store history and indices. AgentSpec maintains (a) the same history , (b) a semantic-block index , with , and (c) one PDA state per request , constant-size each. Thus, , matching NGram asymptotically with only lightweight metadata overhead.