Upgrading Antigravity Loops & Graphs: Contracts, Rubric Checkers, Conditional Routing, and Outer Self-Tuning

By | November 25, 2026

We already had a working Loops & Graphs engine in loop_graph_workflow.py—parallel DAG fan-out, capped inner quality loops (produce → check → fix), and a single human-in-the-loop approval gate.

After reviewing a new multi-agent team architecture prompt, we identified four concrete gaps between basic execution and a self-improving agent team—and wired all four directly into our setup.

What Changed

  1. Structured Node Contracts (JOB / INPUT / OUTPUT / DONE WELL / NEVER / ASK ME FIRST)
    Instead of freeform prompts, each graph node now accepts an explicit contract. Negative boundaries (NEVER) and escalation triggers (ASK ME FIRST) are injected alongside team memory before execution.
  2. Scored “Done Well” Rubric Checker
    Binary shell checks (GREEN/RED) catch syntax and test failures, but miss quality nuances. A dedicated Checker now scores each node’s output (0–100) against its 3–5 item done_well checklist and routes exact fixes back to the node.
  3. Conditional if/then Routing & Mermaid Topology
    Nodes can now define routes (e.g., when: "passed" or "failed") for dynamic handoffs, and every run emits a Mermaid flowchart TD showing the live graph topology.
  4. Outer Improvement Loop (Weekly Self-Tuning)
    Every run logs per-node pass rates, scores, and attempt counts to Meta/states/loop-graph-runs.jsonl. Running --analyze-runs ranks the weakest node and proposes one targeted contract improvement for human approval.

Example Job Prompt

Here is a concrete node prompt rendered by format_contract_prompt:

JOB: Audit nas4 Jellyfin/Podman storage mounts on /mnt/nvme
INPUT: /etc/fstab, podman volume inspect, df -h /mnt/nvme
OUTPUT: Concise health report with free space and mount status
DONE WELL: Verified live via SSH; Reports exact GB free; Flags any read-only mount
NEVER: Restart containers or modify /etc/fstab without approval
ASK ME FIRST: Before pruning unused Podman volumes or images

Why It Matters

Inner loops keep individual tasks green; the outer loop ensures the workflow itself gets sharper over time without silent prompt drift.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.