mlx-optiq
OptiQ Code · Headless & CI

Headless & CI

optiq code -p "GOAL" runs the same agent loop non-interactively: auto-approve, run to completion, print the result and the diff, and set an exit code. It is a claude -p analog for your local model, good for scripts, git hooks, and CI.

Running a goal

terminalbash
$ optiq code -p "Fix the failing test in parser.py. Do not modify the tests."

It prints the stop reason, the turn count, the pass/fail tally, and the salvaged diff, then exits.

Exit codes

CodeMeaning
0The agent declared the goal complete (done).
1The run ended without completing (max turns, wall clock, or no progress). A diff may still have been produced.
2No server reachable, nothing was run.

In CI

Serve a model as a background step, then gate on the exit code. Because a headless run never emits an empty patch, a non-zero exit is a real signal, not a formatting artifact.

ci.shbash
$ optiq serve --model $MODEL --idle-timeout 300 &
$ optiq code -p "Implement the TODO in cache.py so the new tests pass." || exit 1

Limits

Headless runs are bounded: a maximum turn count and an optional wall-clock cap stop a run that is not converging, and per-tool timeouts stop a hung command. Whatever the agent changed up to that point is still returned as a diff.