Most people babysit AI agents because nothing else is checking their work. You watch every step, approve every intermediate edit, and still end up with slow, linear execution.
Inspired by Hanako’s breakdown in Loops and Graphs: how to stop babysitting agents and only approve the last step (mined in 03-Resources/Clippings/2026-11-20 – Loops and Graphs how to stop babysitting agents and only approve the last step (.md), I implemented a reusable Loops-and-Graphs workflow template for Antigravity (agy): /home/gvoina/scripts/loop_graph_workflow.py.
The Core Split: Loops vs. Graphs
- A Loop makes a single unit of work correct without you:
produce -> deterministic check -> fix -> repeat until green. The check must be evaluated by code (exit codes, test suites, linters, schema validators)—never another LLM saying “looks good.” - A Graph shapes the work: what runs in parallel, what depends on what, and where the single human approval gate sits.
How It’s Implemented in agy
loop_graph_workflow.py wires Antigravity’s run_workflow primitives (parallel, phase, agent, log) into three stages:
- Parallel Graph Fan-Out (
parallel): Every independent task inargs["tasks"]runs concurrently in its ownagent()context. - Deterministic Check Loop (
run_checked_loop): Each worker executes its task, thenrun_deterministic_check(check_cmd)runs a real shell command. If the exit code is non-zero, the trailingstdout/stderris fed back into the same worker’s next turn—up tomax_iters. - Single Final Approval Gate: Once all nodes are
GREEN, the workflow prints a concise summary and stops before runningfinal_cmd, unlessapproved=Trueis explicitly passed.
How-To: Running a Loops-and-Graphs Workflow
Pass loop_graph_workflow.py to run_workflow with your tasks, deterministic check_cmds, and a gated final_cmd:
run_workflow(
ScriptPath="/home/gvoina/scripts/loop_graph_workflow.py",
Description="Fix and verify independent modules before deploying",
Args={
"tasks": [
{
"name": "api-tests",
"prompt": "Fix the failing pagination edge case in api/routes.py.",
"check_cmd": "pytest -q tests/test_routes.py",
},
{
"name": "cli-lint",
"prompt": "Resolve type and lint warnings in cli/main.py.",
"check_cmd": "ruff check cli/main.py",
},
],
"max_iters": 3,
"workspace": "share",
"final_cmd": "git commit -am 'Fix pagination and lint' && git push",
"approved": False,
},
)
When all nodes report GREEN, review the summary and re-run with "approved": True to execute final_cmd.
How to Use It Effectively
- Write the
check_cmdfirst: If you can’t express “done” as a command that exits0(e.g.,pytest,ruff,bash -n,antigravity_eval.py), you don’t have a loop—you have a scheduler. - Don’t chain independent tasks: Only put tasks in sequence if one literally consumes the other’s output. Otherwise, put them in
taskssoparallel()runs them together. - Use
workspace="share"for parallel code edits: If multiple workers edit files in the same repo concurrently, give each its own working copy with"workspace": "share". - Cap
max_itersat 3–4: If an agent can’t fix a deterministic failure in 3 attempts, more iterations usually burn tokens; let it surface the failure at the gate. - Gate only the last step: Keep intermediate checks autonomous and reserve
approved=Truefor irreversible actions (pushes, deploys, publishes, or payments).