diff --git a/rust/src/parser/src/output_grammar.rs b/rust/src/parser/src/output_grammar.rs
index 24f24a225c..f19254d364 100644
--- a/rust/src/parser/src/output_grammar.rs
+++ b/rust/src/parser/src/output_grammar.rs
@@ -133,6 +133,13 @@ pub enum OutputGrammarError {
/// A model-specific structural-tag builder rejected its inputs.
#[error("failed to build output grammar")]
Build(#[from] xgrammar_structural_tag::Error),
+ /// A model-specific parser could not project a builder format to its
+ /// visible-output language.
+ #[error("unexpected output grammar shape from `{builder}` builder")]
+ UnexpectedBuilderFormat {
+ /// Builder whose output did not match the parser's known shape.
+ builder: &'static str,
+ },
}
/// Build the visible (post-reasoning) language from a crate structural-tag
@@ -149,6 +156,19 @@ pub(crate) fn visible_format_from_builder(
let Some(builder) = builder else {
return Ok(None);
};
+
+ format_from_builder(
+ builder,
+ ctx,
+ StructuralTagOptions::default().with_reasoning(false),
+ )
+}
+
+fn format_from_builder(
+ builder: &dyn StructuralTagBuilder,
+ ctx: &OutputGrammarContext<'_>,
+ options: StructuralTagOptions,
+) -> Result