Loop
Run iterative verification loops and hillclimbs on Antigravity without manual polling.
How It Works
The /loop skill drives discrete edits against a verification command (--verify "<command>").
It maintains iteration state in <appDataDir>/brain/<conversation-id>/scratch/loop/state.json.
It uses the native Antigravity schedule tool to manage reactive iteration delays.
For open-ended autonomous tasks where no single bash exit code determines completion, use the /goal slash command or the Autonomous run playbook instead.
For standing background jobs or periodic status checks, use the schedule tool directly.
Invocation
Format:
/loop <goal> --verify "<command>" [--max-iterations N] [--interval S]
Default values:
max-iterations: 10interval: 30 seconds
State Machine
The loop maintains durability through structured state transitions.
The file state.json records git revision, active task ID, iteration counters, and status.
During execution, state.json records git revision for each step.
- Frame. Read target files. Generate baseline evidence by executing the verify command via
run_commandor bash. Record initial state in<appDataDir>/brain/<conversation-id>/scratch/loop/state.json. Record the currentgit_revisionfromgit rev-parse HEAD. - Step. Apply one discrete edit or hypothesis. Update
git_revisionif a commit or checkpoint is created. - Verify. Run the verification command. Capture stdout, stderr, and exit code.
- Decide.
- When verify passes, log success, mark status
CONVERGED, and finish. - When verify fails and iterations remain, record the delta, revert regressions if hillclimbing, and set a reactive timer using
schedule(DurationSeconds=interval, Prompt="Loop iteration wakeup for <goal>", TimerCondition="never"). Updatestate.jsonwith the returnedtask_idand next iteration count. - Stop calling tools immediately after scheduling to end the turn and let the timer fire.
- When budget is reached, mark status
EXHAUSTEDand hand back to the user with a summary table.
- When verify passes, log success, mark status
- Wakeup. On schedule trigger, the agent reactively wakes up, reads
state.json, and executes the next step.
Crash and Restart Recovery
The loop recovers gracefully across crashes, context compactions, or server restarts:
- State restoration. On session startup or resume, read
<appDataDir>/brain/<conversation-id>/scratch/loop/state.json. - Revision verification. Compare
git rev-parse HEADwith the recordedgit_revision. If the working tree has drifted, reset to the recorded revision before proceeding. - Deduplication. Inspect the recorded
task_idinstate.json. Usemanage_taskwithAction: "list"orAction: "status"to inspect pending scheduled tasks. - Orphan cleanup. Kill stale or orphaned timers using
manage_taskwithAction: "kill"to prevent duplicate wakeups. - Execution resumption. Resume iteration from the restored state machine position without repeating finished work.
Arguments
| Argument | Description | Default |
|---|---|---|
goal | Description of the desired state | Required |
--verify | Command that exits 0 on success | Required |
--max-iterations | Maximum number of attempts | 10 |
--interval | Delay between iterations in seconds | 30 |


