ag_json_repair
Repair malformed JSON from LLM output or logs into parseable JSON. Use when standard parsing fails, returning the corrected value and repair steps.
Instructions
Repair malformed JSON (LLM output, logs) into parseable JSON.
Deterministically repairs almost-JSON: strips code fences and comments, converts single quotes and Python/JS literals (True/None/undefined), quotes bare keys, removes trailing commas, balances brackets. Returns the parsed value plus the exact repair steps applied. Use when a model or upstream tool emitted JSON that json.parse rejects.
Deterministic, fixture-verified, free for guests (rate-limited; pass your Guild api_key to use your member budget). Returns the result plus a Guild-signed provenance envelope.
payload MUST match this JSON Schema:
{"type": "object", "properties": {"text": {"type": "string", "maxLength": 60000}}, "required": ["text"], "additionalProperties": false}
Output schema: {"type": "object", "properties": {"ok": {"type": "boolean"}, "parsed": {}, "repaired": {"type": "string"}, "changed": {"type": "boolean"}, "steps": {"type": "array", "items": {"type": "string"}}}, "required": ["ok", "parsed", "repaired", "changed", "steps"], "additionalProperties": false}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | ||
| payload | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||