Response Healing
The Response Healing plugin automatically validates and repairs malformed JSON responses from AI models. When models return imperfect formatting – missing brackets, trailing commas, markdown wrappers, or mixed text – this plugin attempts to repair the response so you receive valid, parseable JSON.
Overview
Response Healing provides:
- Automatic JSON repair: Fixes missing brackets, commas, quotes, and other syntax errors
- Markdown extraction: Extracts JSON from markdown code blocks
How It Works
The plugin activates for non-streaming requests when you use response_format with type: "json_schema", and include the response-healing plugin in your plugins array. See the Complete Example below for a full implementation.
What Gets Fixed
The Response Healing plugin handles common issues in LLM responses:
JSON Syntax Errors
Input: Missing closing bracket
Output: Fixed
Markdown Code Blocks
Input: Wrapped in markdown
Output: Extracted
Mixed Text and JSON
Input: Text before JSON
Output: Extracted
Trailing Commas
Input: Invalid trailing comma
Output: Fixed
Unquoted Keys
Input: JavaScript-style
Output: Fixed
Complete Example
Limitations
Non-Streaming Requests Only
Response Healing only applies to non-streaming requests.
Will not repair all JSON
Some malformed JSON responses may still be unrepairable. In particular, if the response is truncated by max_tokens, the plugin will not be able to repair it.