XGrammar-2: Dynamic and Efficient Structured Generation Engine for Agentic LLMs
On the map: LLM agents and tool use → Software engineering coding agents
Abstract (arXiv)
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.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 13 of its 43 references that are in the map. First posted on arXiv 7 Jan 2026.
Builds on
13 of 43 references.
References · 13
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
- 2023Generative Agents: Interactive Simulacra of Human Behaviorcited by 3,500
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 402
- 2025FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Servingcited by 248
- 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
- 2024XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Modelscited by 73
- 2023Grammar Prompting for Domain-Specific Language Generation with Large Language Modelscited by 58
- 2022Validating Large Language Models with ReLMcited by 33
- 2025CONFETTI: Conversational Function-Calling Evaluation Through Turn-Level Interactionscited by 16
- 2023Efficient Semiring-Weighted Earley Parsingcited by 3
- 2020Directed Graph Hashingcited by 2
1 more
Built on by
Citing papers per year: 2026: 6.
6 papers.
- 2026VibeServe: Can AI Agents Build Bespoke LLM Serving Systems?cited by 2
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decodingcited by 2
- 2026Accelerating Constrained Decoding with Token Space Compressioncited by 0
- 2026Neurosymbolic Embodied Agentscited by 0
- 2026Parser States Already Know: Structure-Conditioned KV Persistence for Structured Generationcited by 0
- 2026Provably Tractable NFA-Constrained Language Generation via HMMscited by 0
- 2026Provably Tractable NFA-Constrained Language Generation via HMMs30 Sep 2026
- 2026Parser States Already Know: Structure-Conditioned KV Persistence for Structured Generation28 Aug 2026
- 2026Neurosymbolic Embodied Agents17 Aug 2026
- 2026Accelerating Constrained Decoding with Token Space Compression28 May 2026
- 2026Future Validity is the Missing Statistic: From Impossibility to Phi-Estimation for Grammar-Faithful Speculative Decoding8 May 2026
- 2026VibeServe: Can AI Agents Build Bespoke LLM Serving Systems?7 May 2026
Similar, not cited
Close in wording, no citation either way
- 2026A Policy-Driven Runtime Layer for Agentic LLM Serving
- 2026Efficient LLM Serving for Agentic Workflows: A Data Systems Perspective
- 2026AgentPerfBench: A Benchmarking and Evaluation Suite for Inference Performance of Agentic LLMs
- 2026From Static Templates to Dynamic Runtime Graphs: A Survey of Workflow Optimization for LLM Agents
- 2026Agentic Compilation: Mitigating the LLM Rerun Crisis for Minimized-Inference-Cost Web Automation
- 2026TokenDance: Scaling Multi-Agent LLM Serving via Collective KV Cache Sharing
- 2026Sutradhara: An Intelligent Orchestrator-Engine Co-design for Tool-based Agentic Inference
- 2026Pythia: Exploiting Workflow Predictability for Efficient Agent-Native LLM Serving