Repair output contract violations with minimal field-level patches instead of full-block regeneration.
Minimal-diff repair for output contract violations. When a contract check fails, diagnose the exact field-level mismatch and apply a surgical rename — never regenerate the entire contract block.
Full-block regeneration is wasteful and risky: it discards correct data, introduces regressions, and burns tokens. Most contract failures are simple field-name mismatches (e.g., files_modified vs files_changed) where the data is already correct — only the key needs renaming.
output_contract.required list).files_modified ↔ files_changed, error_count ↔ ).errors| Failure Type | Action |
|---|---|
| Field renamed (data correct, key wrong) | Rename the key in-place |
| Field missing (no equivalent exists) | Add the field with appropriate default or computed value |
| Field type mismatch (string vs list) | Cast/wrap the value to match the schema |
| Structural mismatch (nested vs flat) | Restructure minimally — do NOT regenerate |
Edit tool with exact old_string → new_string targeting only the mismatched field name.output_contract.required fields are now present with correct names.mismatched_fields: List of {expected, actual, action} tuples describing each mismatch found.applied_patches: List of {field, old_name, new_name, file, line} for each rename applied.validation_result: pass or fail after patches applied.Captured from pattern observed in shift_20260331_16_evening_wrap__retry1: agent diagnosed a files_modified vs files_changed mismatch and applied a single targeted rename, avoiding full-block regeneration. This saved tokens, preserved correct data, and reduced retry latency.