Fix bad tool calls
Sometimes the model sends a tool call that is almost right but not valid JSON for tsforge’s schema: a markdown link instead of a file path, a string where an array was expected, a missing required field.
The repair ladder fixes what it can on the harness side before burning another model turn.
Order: validate → try local fix → only then ask the model to retry.
Levels
Section titled “Levels”| Level | Name | When | Example |
|---|---|---|---|
| L0 | Lossless cleanup | always first | unwrap [path](path) → path; drop null fields |
| L1 | Schema coercion | per field | parse a JSON string into an array |
| L2 | Safe defaults | reserved | filled from telemetry over time |
| L3 | Re-ask the model | still invalid | message names the bad field and shows an example |
L0 example
Section titled “L0 example”Model sends file: "[src/foo.ts](src/foo.ts)". L0 unwraps it to src/foo.ts. The edit proceeds without a new model turn.
L3 example
Section titled “L3 example”Model omits required file on edit. L3 tells the model exactly which field is missing, what type was expected, and a sample path. The model retries on the next turn.