For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Python class
GrammarEnforcementSnapshot
GrammarEnforcementSnapshotβ
class max.pipelines.context.GrammarEnforcementSnapshot(in_thinking_region, grammar_enforced, tool_calling_match_buffer, thinking_match_buffer)
Bases: object
Captured grammar-enforcement state for rollback.
The speculative bitmask path walks the enforcement state through
draft tokens to compute downstream slot constraints and then
restores this snapshot so committed-token processing on the next
batch replays the same transitions from a clean state. Lives next
to TextContext because it exposes
TextContext.snapshot_grammar_state() /
TextContext.restore_grammar_state(); the concrete
implementation in TextContext constructs and consumes instances.
-
Parameters:
grammar_enforcedβ
grammar_enforced: bool
in_thinking_regionβ
in_thinking_region: bool
thinking_match_bufferβ
tool_calling_match_bufferβ
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!