Use this recipe when your app needs strict JSON and models occasionally return output that is almost valid, but still breaks your parser.Documentation Index
Fetch the complete documentation index at: https://docs.ai-stats.phaseo.app/llms.txt
Use this file to discover all available pages before exploring further.
1. Start with a structured response contract
Response healing is only useful when the request already asks for structured output. Good triggers:response_format.type = "json_object"- JSON schema style output
- one stable object shape used by multiple callers
2. Enable the plugin at the right layer
You can enableresponse-healing in three places:
- workspace default plugin policy
- preset plugin config
- per-request
plugins
- workspace
- preset
- request
3. Keep the model output narrow
Healing works best when the requested output shape is already constrained. Recommended:- one object, not multiple unrelated blobs
- explicit required keys
- deterministic temperature where possible
- no extra explanatory text requested outside the JSON payload
4. Know what response healing can and cannot do
The current healing path is deterministic and non-streaming only. Streaming requests skip response healing entirely. It can repair:- markdown code fences around JSON
- trailing commas
- missing safe closers
- bare object keys in otherwise recoverable objects
strict mode. Strict mode only unwraps already-valid JSON from fences or surrounding text and skips the broader syntactic repair transforms.
When the request uses JSON Schema style output, healing also validates the recovered payload before rewriting it. The current validator covers common constraints such as:
- required keys
- basic scalar and container types
- enums and const values
- array bounds and
uniqueItems - string length, regex, and common formats such as
email,uri,uuid, anddate-time - number bounds and
multipleOf - object property limits and
additionalProperties: false
- invent missing semantic fields
- guess business values
- rewrite arbitrary prose into valid data
5. Verify that the plugin actually ran
When healing runs, the request details should show plugin execution information. Check:- plugin id
- whether it attempted a transform
- whether the payload changed
- failure reason when the response was not recoverable
- whether the request was non-streaming when you expected healing to run
6. Separate parser problems from content problems
If healing does not help, determine which class of failure you have:- malformed JSON that is still structurally close
- schema-valid JSON with wrong fields
- prose instead of JSON
- truncated output because token limits are too low
7. Roll it out gradually
- enable healing on one preset with stable structured output
- watch plugin execution metadata in logs
- confirm recovered payloads match the expected schema
- widen to similar presets only after the logs look clean
8. Choose the right mode
- Use
safewhen the workflow benefits from bounded syntactic cleanup such as trailing-comma removal or bare-key quoting. - Use
strictwhen the workflow should only accept already-valid JSON once wrappers are removed. - Check the request details to confirm which mode actually ran.