# Benchmarking Procedural Graphs on Flash: -77% Token Variance, +1.9% Cost (N=3)

> 💡 **AI Labo Benchmark Series — Experiment `E60` (Self-Evolving Procedural Graph Guidance)**
>
> Part of our controlled benchmark series testing AI coding agent harnesses inside network-isolated Proxmox VMs (`N=3` counterbalanced `AB`/`BA`/`AB` trials, `temperature=0.7`, 3-UID grading, 90% prefix-cache cost accounting).
> * 🚀 **[Master Benchmark Hub & All Pattern Rankings](https://tappers.hashnode.dev/ai-agent-harness-patterns-benchmark)**
> * 🛡️ **[Anti-Cheating Proxmox & systemd Sandbox Architecture](https://tappers.hashnode.dev/air-gapped-proxmox-systemd-agent-sandbox)**

Google Research's *Procedural Graphs* (`arXiv:2609.09153`) proposes storing agent workflow knowledge as `(procedure, relation, procedure)` triplets—injecting only a 1-hop subgraph per step and letting a verification-gated evolution tool revise bad priors.

We tested this on `models/gemini-3.8-flash` (`LOW`, `N=3`) across a 13-file multi-region release orchestrator (`REL-710`) with 3 split runbooks. While `Flash` self-corrected flawed priors `3/3` times and cut token variance by **`-76.9%`**, single-session runbooks surfaced a clear ceiling—and a crucial **`16384` vs. `32768` output-limit lesson**.

---

## TL;DR — Key Empirical Findings

* **1. `32.00 ± 0.00 / 32` Parity & `3/3` Autonomous Graph Repair:** Both `Baseline (Unconstrained History)` and `Candidate (Procedural Graph Guidance)` scored **`32/32` (`100.0%`)** across all 3 trials (`16` ordering/branching + `16` invariant tests). Seeded with an intentional `[FLAWED_PRIOR]` edge (`T02`), `Candidate` autonomously called `evolve_procedural_graph(op="revise_triple")` before editing in **`3/3` trials** (`1.0` accepted, `0.0` rejected).
* **2. `-76.9%` Token Variance & `-3.37%` Output Tokens, at `+1.87%` Effective Cost:** Fixing `T02` and injecting `~528`-char 1-hop subgraphs cut visible output `-3.37%` (`11,512.3` ➔ `11,124.0`), prompt-token SD **`-81.1%`**, and total-token SD **`-76.9%`** (`3,606.2` ➔ `834.2`). Because `3.8-flash (LOW)` already handled the `~23k`-token runbooks in `8` turns, `Candidate`'s `+1` graph-evolution turn (`9.00` vs. `8.00` calls) added `+12.26%` total tokens and **`+1.87%`** effective cost (`` `$0.0754` `` ➔ `` `$0.0768` ``; list-price `+7.98%`).
* **3. Pre-Rehearsal Discovery (`16384` ➔ `32768` Max Output Tokens):** During `rehearsal-02`, writing 4 modules in one shot under `max_output_tokens=16384` collided with `10k–15.7k` thinking bursts, causing `6` consecutive `MAX_TOKENS` loops (exceeding the `` `$0.50` `` cap). Raising `max_output_tokens=32768` + 1–2 module chunked-write guidance cut truncations from `6/9` to **`0/51` calls** across production!

| Metric (`N=3` Trials, `Mean ± SD`) | Baseline: `Unconstrained History` | Candidate: `Procedural Graph` (`1-hop`) | Delta / Effect |
| :--- | :---: | :---: | :--- |
| **Hidden Grading Suite (`32` Cases)** | **`32.00 ± 0.00`** (`100.0%`) | **`32.00 ± 0.00`** (`100.0%`) | `100%` parity (`16` ord + `16` inv) |
| **LLM Calls (`model_calls`)** | **`8.00 ± 0.00`** (`[8–8]`) | `9.00 ± 0.00` (`[9–9]`) | `+1.00` call (`evolve_procedural_graph`) |
| **`MAX_TOKENS` Hits (`32768` cap)** | **`0 / 24 calls`** | **`0 / 27 calls`** | Down from `6/9` at `16384` cap |
| **Flawed Prior `T02` Self-Repairs** | — | **`3 / 3` (`0` rejections)** | Verified triple revision every trial |
| **Cumulative Input (`prompt_tokens`)** | **`107,966.0 ± 3,767.5`** | `123,004.3 ± 713.4` | `+13.93%` (**`SD -81.1%`**) |
| **Visible Output (`candidates`)** | `11,512.3 ± 197.0` | **`11,124.0 ± 167.7`** | **`-3.37%`** (`-388.3` tokens) |
| **Total Tokens (`total_tokens`)** | **`119,478.3 ± 3,606.2`** | `134,128.3 ± 834.2` | `+12.26%` (**`SD -76.9%`**) |
| **Guest Elapsed (`elapsed_seconds`)** | `237.14s ± 6.10s` | `237.12s ± 6.10s` | `-0.01%` parity |
| **Effective Cached Cost (90% OFF)** | **`` `$0.0754 ± $0.0051` ``** | `` `$0.0768 ± $0.0062` `` | **`+$0.0014` (`+1.87%`)** |
| **List-Price Upper Bound (No Cache)** | **`` `$0.1241 ± $0.0023` ``** | `` `$0.1340 ± $0.0011` `` | `+7.98%` (`` `+$0.0099` ``) |

---

## 1. Experiment Design & Architecture

```text
+-----------------------------------------------------------------------+
| Proxmox VM265 (0 NICs, 3.8-flash LOW, max_out=32768, N=3 AB/BA)       |
| Task: 13-File Release Orchestrator + 3 Split Runbooks (32 Tests)      |
|                                                                       |
| Baseline (Unconstrained History):                                     |
|   inspect (2x) -> checks -> write (2x) -> checks -> submit (8 calls)  |
|   --> $0.0754 eff. | 119,478 tok (SD 3,606) | 0 MAX_TOKENS | 32/32    |
|                                                                       |
| Candidate (Procedural Graph Guidance + 1-hop Subgraph Injection):     |
|   inspect -> evolve_procedural_graph (fixes T02 [FLAWED_PRIOR])       |
|   -> 1-hop subgraph (~528c/turn) -> write (2x) -> submit (9 calls)    |
|   --> $0.0768 eff. (+1.87%) | 134,128 tok (SD 834, -76.9%) | 32/32    |
+-----------------------------------------------------------------------+
```

Because `Candidate` preserved full message history (avoiding artificial pruning confounders), `E60` isolates the exact cost of maintaining and consulting a live procedural graph on top of `Flash`'s 1M context window.

---

## 2. Drop-In Implementation Recipe: `ProceduralGraphStore`

Gate graph mutations against cycle/contradiction checks, archive rejected edits in `rejection_memory`, and inject only the `1`-hop neighborhood around the current execution step:

```python
class ProceduralGraphStore:
    """Verification-gated procedural triplet store with rejection memory."""

    def __init__(self, edges: list[dict]) -> None:
        self.edges = {e["id"]: dict(e) for e in edges}
        self.rejection_memory: list[dict] = []

    def evolve_triple(self, edge_id: str, new_src: str, rel: str, new_dst: str, evidence: str) -> str:
        if new_src == new_dst or not evidence.strip():
            self.rejection_memory.append({"edge_id": edge_id, "reason": "SELF_LOOP_OR_NO_EVIDENCE"})
            raise ValueError("REJECTED_EVOLUTION: invalid cycle or missing runbook evidence")
        if any(e["src"] == new_dst and e["dst"] == new_src for k, e in self.edges.items() if k != edge_id):
            self.rejection_memory.append({"edge_id": edge_id, "reason": "ORDER_INVERSION"})
            raise ValueError("REJECTED_EVOLUTION: reverses an existing dependency edge")
        self.edges[edge_id] = {"id": edge_id, "src": new_src, "rel": rel, "dst": new_dst}
        return f"ACCEPTED:{edge_id} ({new_src} -[{rel}]-> {new_dst})"

    def render_1hop_subgraph(self, focus_node: str) -> str:
        local = [e for e in self.edges.values() if focus_node in (e["src"], e["dst"])]
        return "\n".join(f"- [{e['id']}] {e['src']} --({e['rel']})--> {e['dst']}" for e in local)
```

* **Why this works:** Validation gates block hallucinated cycles before they enter agent memory, while `1`-hop rendering keeps procedural hints to ~`500` chars per turn.

---

## 3. Threats to Validity & When NOT to Use This

1. **Written Runbooks vs. Multi-Episode Discovery:** `arXiv:2609.09153` targets multi-episode discovery across `50+` sessions where no static runbook exists. When all rules already live in `~20k` tokens of readable runbooks inside one `9`-turn session, `3.8-flash LOW` fits everything comfortably (`32/32`), leaving no room for accuracy gains.
2. **Additive Graph vs. History Pruning:** We appended `1`-hop subgraphs without pruning raw history to preserve `functionCall`/`functionResponse` pairing symmetry. Combining graphs with selective pruning (`E61`) in `50+`-turn workflows remains open for follow-up.
3. **Sample Size & Output Cap:** `N=3` on `tier1_flash_low` (`temperature=0.7`) established variance stabilization (`-76.9%`) and `32768`-token output safety; longer horizons may shift the `+1.87%` net cost delta.

<details>
<summary>📋 Experiment Metadata & Reproducibility</summary>

* **Experiment ID:** `E60` (`C056` / Google Research `arXiv:2609.09153` / Benchmark v2.1)
* **Run ID:** `e60-20261124-vm265-01` (`N=3` trials: `AB` ➔ `BA` ➔ `AB`, `temperature=0.7`)
* **Sandbox Environment:** Proxmox Isolated VM `VM265` (0 NICs, Debian 13, 3-UID isolation: `labexp60` / `labrunner60` / `labjudge60`)
* **Model Tier:** `tier1_flash_low` — `models/gemini-3.8-flash` (`thinkingLevel="LOW"`, `max_output_tokens=32768`, budget cap `` `$0.50` ``)
* **Cost Accounting:** Google 90% implicit prefix-cache discount (`effective_cached_micro_usd`) as primary metric; list-price upper bound reported alongside.

</details>

---

**Discussion:** Have you hit silent `MAX_TOKENS` loops when letting `Flash`-class models edit 4+ modules at once under a `16k` output cap?

### 🔗 Continue Reading the Series
* 🚀 **Master Benchmark Hub:** [AI Agent Harness Patterns Benchmark](https://tappers.hashnode.dev/ai-agent-harness-patterns-benchmark)
* 🛡️ **Methodology & Sandbox Architecture:** [How to Benchmark AI Agents Without Eval Cheating or API Key Leaks: Designing a Proxmox & systemd Sandbox](https://tappers.hashnode.dev/air-gapped-proxmox-systemd-agent-sandbox)
* ⬅️ **Previous Post (`E59`):** [Conditional Guardrail Routing Cuts False Positives 100%—When Does It Pay Off?](https://tappers.hashnode.dev/e59-trajectory-learned-conditional-guardrail)
* ➡️ **Next Post (`E61`):** [Why Blind Tool-Output Elision Backfires: Cache Busting & +40.1% Cost (N=3)](https://tappers.hashnode.dev/e61-staged-rule-based-elision)
* 🔄 **Related Self-Evolution (`E50`):** [Self-Evolving Agent Harnesses Cut Variance by 59%—But Cost +17% More (N=3)](https://tappers.hashnode.dev/e50-observability-driven-automatic-harness)
