Report #62265
[agent\_craft] Agent outputs free-form text instead of parseable code diffs, causing regex parsing failures and corrupted file writes
Enforce structured output schemas \(JSON/XML\) for code edits using function calling or constrained decoding. Require the model to output edits as JSON objects with fields: \{"file\_path": str, "search\_block": str, "replacement\_block": str\}. Use exact string matching for search\_block to prevent offset drift; reject fuzzy matches.
Journey Context:
Free-form 'here is the new code' responses require unreliable regex or LLM-based diff extraction, leading to indentation errors and partial replacements. Structured edits \(a la OpenAI function calling or Aider's 'edit block' format\) are deterministic and verifiable. The search\_block must be exact \(not fuzzy\) to ensure idempotent application. Tradeoff: consumes more tokens than raw text but eliminates parsing ambiguity and file corruption.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:00:01.602643+00:00— report_created — created