mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2893] [Engine] Opt-in LaTeX-safe JSON recovery for json_object responses (LightRAG VLM) #1168
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#1168
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BoysGameStudio on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2893
Summary
When a vision-language model generates JSON containing an unescaped LaTeX
backslash, Strata's
response_format: {"type":"json_object"}validationrejects the completion with HTTP 502 (
structured_output_failed).This breaks LightRAG's multimodal PDF ingestion because LightRAG already
implements tolerant JSON parsing and LaTeX escape recovery, but Strata
rejects the response before LightRAG can access the generated text.
The issue has been reproduced using the same image and prompt.
Environment
Minimal Reproduction
Model-generated content:
The sequence
\ais not a valid JSON escape.This can also be reproduced directly against Strata's validator:
Actual Behavior
structured_output_failed).Expected Behavior
An optional recovery mode could repair unambiguous LaTeX escaping errors
before strict validation.
For example:
The repaired output should still pass strict JSON validation before
being returned to the client.
Proposed Solution
Introduce an opt-in, conservative JSON recovery mechanism for
response_format=json_object.Suggested behavior:
json_schemabehavior.The implementation must also account for LaTeX commands such as:
\alpha\beta\frac\tau\nablaSome commands conflict with valid JSON escape sequences, so simply
doubling every backslash is unsafe.
Regression tests should cover legitimate JSON escapes, already-correct
LaTeX escaping, duplicate keys, invalid constants, and truncated output.
Related Issues and PRs
https://github.com/HKUDS/LightRAG/pull/3238
https://github.com/HKUDS/LightRAG/pull/3242
Constrained decoding may prevent syntactically invalid JSON, but it does
not necessarily preserve LaTeX semantics when a model emits JSON-valid
escape sequences.
This feature would improve compatibility with LightRAG and other
applications processing mathematical or technical documents.
Retest (2026-10-21)
Retested on Strata 0.2.0-beta (source, tag
v0.2.0-beta) and on the current release (Strata 0.2.1.4source build, engine
strata 0.1.46.3). Still reproduces on both;serve/structured.pyis unchangedsince v0.1.44.1.
response_format: {"type":"json_object"}, a completion containing{"description":"$\alpha_0 > 1$"}gives HTTP 502structured_output_failed(validator:Invalid \escape), and the text never reaches the client. Reproduced on both with the built-in mockengine (
--engine mock --script), which is the same validation path. Not reproduced with a realmodel: my runs escaped the backslashes correctly, so the rejection comes from the validator, not the
model.
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.
@BoysGameStudio commented on GitHub (Oct 21, 2026):
Retested on a source build of the current release — still reproduces.
strata 0.1.46.3(CUDA 13.4, sm_120).serve/structured.pyis unchanged since v0.1.44.1.
response_format: {"type":"json_object"}, a completion containing{"description":"$\alpha_0 > 1$"}gives HTTP 502structured_output_failedand the text neverreaches the client. Reproduced with the built-in mock engine (
--engine mock --script), which is thesame validation path. Not reproduced with a real model: my runs escaped the backslashes correctly, so
the rejection comes from the validator, not the model.
@BoysGameStudio commented on GitHub (Oct 21, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 21, 2026):
Not reopened yet. Still missing:
Edit the issue and comment
/reopenagain. Details: CONTRIBUTING.md@BoysGameStudio commented on GitHub (Oct 21, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 21, 2026):
Not reopened yet. Still missing:
Edit the issue and comment
/reopenagain. Details: CONTRIBUTING.md@BoysGameStudio commented on GitHub (Oct 21, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 21, 2026):
Reopened, thank you. A maintainer will pick it up from here.
@Niko1221 commented on GitHub (Oct 27, 2026):
Thank you. Fixed in 0.2.7: Opt-in LaTeX-safe JSON recovery for structured output.
Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.7