XGrammar-2 is an upgraded framework for structured generation in AI agent applications, introducing Structural Tag—a unified JSON protocol for expressing tool calls, reasoning channels, and custom output formats. It features efficiency optimizations like cross-grammar caching and speculative decoding support, and has been adopted by major AI companies including xAI, Databricks, and DeepSeek.