sgl-project/sglang · error · NotImplementedError
structure_info not used for JSON schema constraints
Error message
structure_info not used for JSON schema constraints
What it means
Raised by JsonArrayParser.structure_info() because JSON-array function-call parsers do not provide a StructureInfo factory; JSON-schema constraints are handled directly by the constraint backends (e.g. xgrammar/outlines) instead. Calling this method on this parser subclass is a programming error, not a runtime data problem.
Source
Thrown at python/sglang/srt/function_call/json_array_parser.py:51
raise NotImplementedError(
"Detect and parse not supported for JSON schema constraints."
)
def parse_streaming_increment(
self, new_text: str, tools: List[Tool]
) -> StreamingParseResult:
"""
Streaming incremental parsing with tool validation.
"""
return super().parse_streaming_increment(new_text, tools)
def structure_info(self) -> callable:
"""
Return a function that creates StructureInfo for constrained generation.
This is not used for JSON schema constraints as they are handled
by the constraint backends directly.
"""
raise NotImplementedError("structure_info not used for JSON schema constraints")
View on GitHub (pinned to 0132848349)
Solutions
- Guard the call with hasattr(parser, 'structure_info') or check parser type before calling
- Use a parser that implements structure_info (e.g. a structural-tag-based detector) if constrained-generation StructureInfo is required
- Refactor the call site to only invoke structure_info on parsers that declare it
Example fix
// before
info = parser.structure_info()
// after
if not isinstance(parser, JsonArrayParser):
info = parser.structure_info() Defensive patterns
Strategy: type-guard
Type guard
def has_structure_info(p) -> bool:
return hasattr(p, "structure_info") and not isinstance(p, JsonArrayParser) Prevention
- Check parser type before calling optional parser APIs
- Treat structure_info as opt-in per parser family
When it happens
Trigger: Calling .structure_info() on a JsonArrayParser instance (or any code path that assumes every FunctionCallParser implements structure_info) while using the JSON array tool-call format.
Common situations: New code that iterates over tool parsers and unconditionally calls structure_info(); switching a server to the json_array parser type while retaining logic written for chat-template/structural-tag parsers like KimiK3.
Related errors
- Kimi K3 uses its model-native structural tag implementation
- /v1/models ${response.status}
- Unsupported msgpack byte ${b}
- This browser does not support gzip stream decoding
- {self._op_label()}: no triton backend
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/f82c79e346123b3f.
Report an issue: GitHub.