Detect and automatically repair malformed, truncated, or structurally invalid model responses.
Not yet available. Response Healing is not yet available.
Models occasionally produce outputs that are structurally wrong — a JSON block that isn't valid JSON, a Markdown table with a missing column, a response that stops mid-sentence because max_tokens was hit. Response Healing is a response-phase plugin that catches these cases and attempts a repair before your application ever sees the output.
| Problem | Healing action |
|---|---|
| Invalid JSON (unclosed braces, trailing comma) | Attempt structural repair; re-request if unrecoverable |
| Truncated JSON or code block | Complete the structure syntactically |
Response cut off mid-sentence by max_tokens | Issue a continuation request and splice the result |
| Markdown table column mismatch | Pad or trim cells to align with the header |
| Empty response | Re-request once with a nudge instruction |
Healing runs synchronously. If repair succeeds, the corrected response is returned as normal. If repair fails after the configured retry budget, the original (broken) response is returned with an X-Healing-Failed: true header.
| Option | Type | Default | Description |
|---|---|---|---|
targets | array | ["json", "truncation", "empty"] | Which problem classes to heal |
max_retries | integer | 1 | How many additional model calls healing may make |
strict | boolean | false | Return a 502 error instead of the broken response on failure |
X-Healing-Applied: true — at least one repair was made.X-Healing-Failed: true — healing was attempted but the result is still invalid (only when strict: false).Each healing retry is a fresh model invocation billed at the original model's DA rate. Structural repairs that don't require a retry (e.g., closing a brace) have no additional token cost.