

















Abstract:Modern LLM agents increasingly rely on dynamic structured generation, such as tool calling and response protocols. Unlike traditional structured generation with static structures, these workloads vary both across requests and within a request, posing new challenges to existing engines. We present XGrammar-2, a structured generation engine for dynamic agentic workloads. Our design is based on two key ideas: first-class support for tag-triggered structure switching, and fine-grained reuse across requests with different output structures. Concretely, XGrammar-2 introduces TagDispatch for dynamic structural dispatching and Cross-Grammar Cache for substructure-level cache reuse across grammars. It further improves efficiency with an Earley-based adaptive token mask cache, just-in-time compilation, and repetition state compression. Experiments show that XGrammar-2 achieves over 6x faster compilation than prior structured generation engines, and incurs near-zero end-to-end overhead in modern LLM serving systems.
| Comments: | 10 pages, ACM CAIS 26 |
| Subjects: | Artificial Intelligence (cs.AI) |
| ACM classes: | I.2.11 |
| Cite as: | arXiv:2601.04426 [cs.AI] |
| (or arXiv:2601.04426v3 [cs.AI] for this version) | |
| https://doi.org/10.48550/arXiv.2601.04426 arXiv-issued DOI via DataCite |
|
| Related DOI: | https://doi.org/10.1145/3786335.3813124
DOI(s) linking to related resources |
From: Linzhang Li [view email]
[v1]
Wed, 7 Jan 2026 22:18:51 UTC (397 KB)
[v2]
Thu, 26 Mar 2026 02:27:05 UTC (481 KB)
[v3]
Mon, 25 May 2026 20:48:59 UTC (854 KB)
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。