Skip to content

fix: reject unsupported whitespace_pattern in SGLang and TGI adapters - #2004

Open
uuzzrm wants to merge 1 commit into
dottxt-ai:mainfrom
uuzzrm:fix/whitespace-pattern-server-integrations
Open

uuzzrm wants to merge 1 commit into
dottxt-ai:mainfrom
uuzzrm:fix/whitespace-pattern-server-integrations

Conversation

@uuzzrm

@uuzzrm uuzzrm commented Aug 14, 2026

Copy link
Copy Markdown

Closes #1998

SGLangTypeAdapter was silently dropping JsonSchema.whitespace_pattern. The SGLang OpenAI-compatible API doesn't accept a per-request whitespace pattern — it's only configurable at server startup via --constrained-json-whitespace-pattern — so mirroring the vLLM adapter and stuffing the field into response_format would have been a silent no-op. I made the adapter raise a clear NotImplementedError instead, which is what the llguidance and xgrammar backends already do for the same reason.

The TGI adapter had the exact same gap (TGI's grammar API has no whitespace option either), so it now raises too.

  • SGLangTypeAdapter: raise when whitespace_pattern is set, with a pointer to the server-side flag
  • TGITypeAdapter: raise when whitespace_pattern is set
  • Updated both adapter tests that previously asserted the ignored behavior
  • Docs: noted that the SGLang and TGI integrations reject whitespace_pattern

Verified against the SGLang and TGI servers: neither exposes a per-request whitespace pattern (only the SGLang server flag). Tested with the repo-pinned ruff 0.9.1 (clean) and the sglang/tgi/vllm adapter tests.

Developed with AI assistance and reviewed before submission.

The SGLang OpenAI-compatible API only exposes a server-side whitespace pattern (--constrained-json-whitespace-pattern), so forwarding the field into response_format would be a silent no-op. Raise a clear error instead, matching the llguidance and xgrammar backends. The TGI grammar API has the same limitation, so it now raises too.

Closes dottxt-ai#1998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SGLangTypeAdapter silently drops whitespace_pattern from JsonSchema (vLLM backend handles it correctly)

1 participant