# Slashing Swarm Benchmark Cost 94.9%: Why Carbon LOW Failed and Flash LOW Won

> 💡 **AI Labo Benchmark Series — Experiment `E56a` (Cost-Optimization Ablation on `E56`)**
>
> 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)**

In [`E56`](https://tappers.hashnode.dev/e56-shepherd-search-branch-swarm), running our Shepherd branch swarm benchmark on `gemini-4-carbon (MEDIUM)` cost `` `$11.27` `` across 3 trials—and **`53.9%` (`` `$6.07` ``) was burned on `19` `MAX_TOKENS` truncations**! Our first instinct was simple: downgrade `gemini-4-carbon` from `MEDIUM` to `LOW`.

That failed immediately—tripping a `` `$2.00` `` budget cap mid-run. So we re-ran the **exact same `E56` fixture and 32-case grader** on symmetric `gemini-3.8-flash (LOW)` (`N=3`), cutting suite cost by **`-94.94%` (`19.8x` cheaper)** with **`0` truncations**.

---

## TL;DR — Key Empirical Findings

* **1. Why Naive `Carbon LOW` Downgrade (`plan-a`) Failed:** Lowering `gemini-4-carbon` to `LOW` (`16,384` max tokens) did **not** stop runaway internal reasoning during multi-file generation. In `plan-a`, `Baseline (Carbon LOW)` hit `MAX_TOKENS` `4/11` times in Trial 1 (`` `$0.8767` `` wasted) and `6/9` times in Trial 2 (`16,381` tokens per truncation), blowing past the `` `$2.00` ``/trial budget cap (`usd_cap_exceeded`) at `seq=20`.
* **2. Symmetric `gemini-3.8-flash LOW` (`plan-a-rev`) Cut Cost `-94.94%` & Sped Up `9.09x`:** Across `N=3` trials on the identical `E56` fixture, switching both modes to `gemini-3.8-flash (LOW)` dropped 3-trial effective cached cost from `` `$11.2666` `` to **`` `$0.5696` `` (`-94.94%`, `1/19.8th`)**, eliminated **`MAX_TOKENS` (`19/70` ➔ `0/43` calls; `` `$6.0698` `` ➔ `` `$0.0000` `` wasted)**, and cut total runtime from `9,897.56s` (~165 min) to **`1,088.71s` (~18.1 min, `9.09x` faster)**.
* **3. Eliminating `MAX_TOKENS` Revealed the True Task Ceiling:** Once `0` truncations occurred, both modes passed **`32.00 ± 0.00 / 32`** across all 3 trials (`Baseline`: `99.88 ± 0.21%` vs. `Candidate`: `99.91 ± 0.16%` unseen optimality, `+0.03 pt`). Part of `E56`'s `Carbon MEDIUM` accuracy gap (`93.3%` vs. `100%`) had been amplified by `MAX_TOKENS` starving Trial 1 of a refinement turn—proving why a **cheap `N=1` Flash pre-rehearsal** must gate frontier runs.

| Metric (`N=3` Suite on Identical `E56` Task) | Original `E56`: `Carbon MEDIUM` | `plan-a-rev`: `Flash LOW` (`N=3`) | Delta (`plan-a-rev` vs. `E56`) |
| :--- | :---: | :---: | :--- |
| **3-Trial Effective Cost (90% OFF)** | `` `$11.2666` `` (list `` `$12.3332` ``) | **`` `$0.5696` `` (list `` `$0.7252` ``)** | **`-94.94%` (`19.8x` cheaper)** |
| **Total Model Calls / `MAX_TOKENS`** | `70` calls / **`19` hits (`27.1%`)** | **`43` calls / `0` hits (`0.0%`)** | **`-38.6%` calls / `-100%` hits** |
| **Wasted Spend on `MAX_TOKENS`** | `` `$6.0698` `` (`53.9%` of total!) | **`` `$0.0000` `` (`0.0%`)** | **`` `-$6.0698` `` waste eliminated** |
| **Total Suite Time (`N=3`)** | `9,897.56s` (~165 min) | **`1,088.71s` (~18.1 min)** | **`9.09x` faster (`-89.0%`)** |
| **Mode A Cost / Unseen Score (`32`)** | `` `$1.4470` `` / `30.33 ± 2.89` (`93.3%`) | **`` `$0.0477 ± $0.0186` `` / `32/32` (`99.88%`)** | **`-96.7%` cost**, `17.4x` faster |
| **Mode B Cost / Unseen Score (`32`)** | `` `$2.3085` `` / `32.00 ± 0.00` (`100.0%`) | **`` `$0.1422 ± $0.0438` `` / `32/32` (`99.91%`)** | **`-93.8%` cost**, `9.4x` faster |

---

## 1. Experiment Design & 3-Tier Escalation Architecture

```text
+-----------------------------------------------------------------------+
| Proxmox VM264 (0 NICs, Exact E56 Fixture & 3-UID 32-Case Grader)      |
|                                                                       |
| Ablation 1 (plan-a: Carbon LOW 16k on Mode A & Shepherd):             |
|   T1: $1.701 (4 MAX_TOKENS) -> T2: 6 MAX_TOKENS -> HALTED ($2.00 cap) |
|                                                                       |
| Ablation 2 (plan-a-rev: Symmetric 3.8-flash LOW on all roles, N=3):   |
|   Pre-rehearsal (N=1): $0.2097, 0 MAX_TOKENS, 32/32 PASS              |
|   Production (N=3): T1 $0.136 | T2 $0.181 | T3 $0.253 -> $0.5696 total|
+-----------------------------------------------------------------------+
```

From `E56a` onward, AI Labo standardized a **3-Tier Model Escalation Policy**: start every standard harness comparison at **Tier 1 (`gemini-3.8-flash LOW`, `max_output_tokens=32768`, `` `$0.50` `` trial cap)** with an `N=1` rehearsal, escalate to **Tier 2 (`3.8-flash MEDIUM`, `` `$1.00` `` cap)** only if `Flash LOW` drops below `80%` on unseen tests, and reserve **Tier 3 (`gemini-4-carbon`)** strictly for cross-generation or frontier-specific hypotheses.

---

## 2. Drop-In Implementation Recipe: Tier Gate & Hard Budget Cap

Enforce symmetric model selection, generous output ceilings (`32768` so thinking tokens never collide with multi-file code writes), and a hard micro-USD circuit breaker inside your LLM relay:

```python
TIERS = {
    "tier1_flash_low": {"model": "gemini-3.8-flash", "thinking": "LOW", "max_out": 32768, "cap_usd": 0.50},
    "tier2_flash_med": {"model": "gemini-3.8-flash", "thinking": "MEDIUM", "max_out": 32768, "cap_usd": 1.00},
    "tier3_carbon": {"model": "gemini-4-carbon", "thinking": "MEDIUM", "max_out": 32768, "cap_usd": 2.50},
}


def select_benchmark_tier(rehearsal_unseen_pct: float, requires_frontier_behavior: bool) -> dict:
    """Routes benchmarks to the cheapest tier with sufficient discriminative power."""
    if requires_frontier_behavior:
        return TIERS["tier3_carbon"]
    if rehearsal_unseen_pct < 80.0:
        return TIERS["tier2_flash_med"]
    return TIERS["tier1_flash_low"]


def guard_relay_budget(spent_micro_usd: int, tier: dict) -> None:
    """Hard relay circuit breaker preventing silent $11+ benchmark runaways."""
    cap_micro = int(tier["cap_usd"] * 1_000_000)
    if spent_micro_usd >= cap_micro:
        raise RuntimeError(f"USD_CAP_EXCEEDED: {spent_micro_usd} >= {cap_micro} micro-USD")
```

* **Why this works:** Pairing an `N=1` Flash rehearsal with a hard `usd_cap_micro` relay stop detects both ceiling effects and runaway `MAX_TOKENS` loops before committing to an `N=3` frontier sweep.

---

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

1. **Task Ceiling vs. Harder Frontier Problems:** `E56a` proved `3.8-flash LOW` nearly maxed out `E56`'s `specinfer-scheduler-v2` fixture (`99.88%` vs. `99.91%`), meaning `E56` did not require `Carbon`'s deep reasoning once `MAX_TOKENS` was removed. Harder tasks with undocumented legacy traps (`E46`: `30/34` vs. `34/34`) still require frontier models.
2. **Output Cap (`16,384` vs. `32,768`):** While `3.8-flash LOW` produced `0` `MAX_TOKENS` at `16,384` here, `E60` later showed `Flash` can still hit `16,384` when writing 4+ modules in one shot—so set `max_output_tokens=32768` and instruct 1–2 module chunked writes.
3. **When to Keep `Carbon`:** Keep `gemini-4-carbon` when the research question explicitly targets frontier reasoning behavior (e.g., double-thinking tax `E47`, spec-conflict governance `E49`, or undocumented invariant discovery `E46`).

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

* **Experiment ID:** `E56a` (Cost-Optimization Ablation on `E56` / Benchmark v2.1)
* **Run IDs:** `e56a-20261123-vm264-01-rehearsal` (`N=1`), `plan-a` (halted T2 `seq=20`), `plan-a-rev` (`N=3`: `AB` ➔ `BA` ➔ `AB`, `temperature=0.7`)
* **Sandbox Environment:** Proxmox Isolated VM `VM264` (0 NICs, `PrivateNetwork=yes`, 3-UID isolation: `labexp56` / `labrunner56` / `labjudge56`)
* **Models:** `models/gemini-4-carbon` (`LOW`, failed) vs. `models/gemini-3.8-flash` (`LOW`, `N=3` passed)
* **Cost Accounting:** Google 90% implicit prefix-cache discount (`effective_cached_micro_usd`) as primary metric; list-price upper bound reported alongside.

</details>

---

**Discussion:** When an agent benchmark gets too expensive or hits `MAX_TOKENS`, do you first lower `thinkingLevel` on the frontier model—or drop down to a `Flash`-class model?

### 🔗 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)
* ⬅️ **Parent Benchmark (`E56`):** [Shepherd Branch Swarms Beat Public-Test Overfitting: 100% vs. 93.3% (N=3)](https://tappers.hashnode.dev/e56-shepherd-search-branch-swarm)
* ⚖️ **Related Cross-Gen Boundary (`E46`):** [Cross-Generation Capability vs. Cost Boundary: Unharnessed Gemini 4 Carbon (HIGH) vs. Harnessed 3.8 Flash (LOW) (-88.6% Cost, N=5)](https://tappers.hashnode.dev/e46-carbon-giant-killing-v2)
* ✂️ **Related Subtraction Tax (`E47`):** [Measuring the Double-Thinking Tax on Gemini 4 Carbon: Subtracting Legacy Scaffolding Cuts Effective Cost by 30.9% (N=3)](https://tappers.hashnode.dev/e47-carbon-harness-subtraction-tax)
