Response Healing
Automatically fix malformed JSON responses
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
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 either type: "json_schema" or type: "json_object", 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
Using with JSON Schema
If the selected model and provider support json_schema, you can replace the response_format in the example above with the following configuration, while retaining the plugin and non-streaming parameters:
This configuration requires category and priority, and rejects undeclared fields. Listing a field in properties does not make it mandatory; use required for that. See the JSON Schema object reference.
Note
Response Healing repairs JSON formatting; it does not validate the schema. Even with
strict: true, the plugin does not check required fields, types or enum values. Structured generation capabilities still depend on the model and provider, and applications should retain result validation.
Limitations
Last updated