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
- 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. - 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 itemdone_wellchecklist and routes exact fixes back to the node. - Conditional
if/thenRouting & Mermaid Topology
Nodes can now defineroutes(e.g.,when: "passed"or"failed") for dynamic handoffs, and every run emits a Mermaidflowchart TDshowing the live graph topology. - Outer Improvement Loop (Weekly Self-Tuning)
Every run logs per-node pass rates, scores, and attempt counts toMeta/states/loop-graph-runs.jsonl. Running--analyze-runsranks 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.