mlx-optiq
OptiQ Code · Robustness

Robustness

This is the product's edge: the engineering that keeps a weak local model productive where it would otherwise fail on the mechanics. Each guarantee targets a specific failure mode.

Never an empty patch

Every exit path (done, max turns, wall clock, or an error mid-run) salvages the working git diff before returning. A model that edits a file and then crashes or runs out of turns still hands back the change.

Edit-apply resilience

When an exact-match edit_file keeps missing on the same file (an off-by-a-space old string), the harness stops the retries and nudges a full-file rewrite with write_file instead of dead-ending on one file.

Stall → force-write

Turns of reading with no edit, or a repeated response, trip a nudge: make one small, testable change, then run the tests. Progress is measured against the pass/fail count, not the text, so the agent cannot "look busy" while standing still.

Format robustness

ANSI escapes are stripped from tool output before the model sees them, and a tool call the model wrote as a ```json block instead of a structured call is healed into a real call. A format slip does not cost a turn.

Bounded & resumable

Per-tool timeouts stop a hung command, an optional wall-clock cap stops a run that is not converging, and the trajectory is append-only across context resets, so long runs stay coherent.

Transient-failure retry

A server still warming up (a Metal kernel compiling on the first request) or a transient blip is retried, not counted as a model failure.

A worked example

Here is a real run on a planted off-by-one bug (adjacent intervals [1,2] and [2,3] should merge to [1,3]), driven by a local 27B:

optiq code -ptext
baseline: 0 passed, 1 failed
⏺ search(glob='**/*.py')
⏺ read_file(path='intervals/__init__.py')
  ⎿ 12 lines
⏺ edit_file  # strict < → <= so touching intervals merge
  ⎿ auto-verify after edit → 1 passed, 0 failed
⏺ done — Fixed the off-by-one: touching intervals now merge.

stop: done  turns: 5  tests: 1 passed / 0 failed

The agent grounded the change by reading the file, made one targeted edit, and the harness auto-verified with the tests before the model even asked. The pass count is what let it declare done with confidence.