Warden-S1: A Sub-1GB, 128K-Context System-One Model for Coding Agents
What this is: Most AI models are slow System-2 talkers that generate paragraphs of text. Warden-S1 is a local System-1 model with its own 128K-token context window and a twist: in one instant neural reflex pass (0 generated chat tokens), it outputs calibrated Yes/No probabilities, category Choices, and Severity scores to guard long-running AI coding agents (catching secret leaks from poisoned issues 70,000 tokens back or fake “all tests pass” claims).
Existing cloud System-1 judges crash past their ~33K-token ceiling (HTTP 400) and upload your private repo to an API, while normal “small” local models secretly eat 14.3 GB of RAM when stretched to a 128K window and freeze a laptop on one chat. Warden-S1 holds 10 concurrent long-context sessions at once in 858 MB on your laptop (or 461 MB inside Chrome), beats commercial Cloud Jev (96.1% vs. 84.9%), admits “I don’t know” at 0.50 instead of bluffing, points to the exact guilty turn (locus), and scores which old turns are safe to compact (salience) so Warden-S1’s 128K window keeps tracking even when your main coding agent’s session grows past 500K+ tokens.
What you experience in the browser playground below is a much smaller, sandboxed preview of Warden-S1’s true usage: running natively as a persistent background companion to your coding-agent harness (such as pi-warden), where it streams incremental turn updates 15× to 20× faster (~300-500 ms per new turn, pre-warmed while your main LLM thinks) across 10+ live repositories at once.
Why Build a Dedicated Local Verification Model?
When I built pi-warden, the goal was practical: stop AI coding agents from running destructive commands, leaking secrets, or declaring victory without proving their work, while steering them inline instead of interrupting the human on routine steps.
Deterministic rules (System-0) catch explicit pattern violations in under 1 ms with zero model calls. The harder checks are semantic: noticing that an agent read an untrusted external page forty thousand tokens ago and is now quietly interpolating an environment secret into an outbound request, catching trajectory oscillation, or judging whether a long verification trace actually proves what the agent claims.
Calling frontier cloud models as secondary judges (pi-typesafe) works well on short contexts, yet hits three walls when running 10+ concurrent coding-agent sessions across multi-hour, 100K-to-500K+-token sessions all day:
- Context ceiling, latency, and cost on long prefixes: Commercial System-One endpoints reject payloads past
~32Ktokens (~101 KiB), and re-shipping60K-100Ktranscript tokens over the network on ambiguous turns adds seconds of tail latency and steady API spend. - Privacy boundary: Local engineering transcripts hold diffs and environment context that should not have to leave the machine just to run a guardrail check.
- The dense KV-cache wall on laptops: Even a small
0.6Bdense transformer (28full GQA layers) consumes7.2 GiBat64Ktokens and14.3 GiBat128Ktokens in BF16 KV state alone, blowing through a 16 GB laptop's unified memory on a single session.
The engineering constraint I set for Warden-S1 was strict: keep total live GPU residency under 1,024 MiB (< 1 GiB) on Apple Silicon Metal (weights plus live sequence state) at 64K to 128K tokens across 10+ concurrent sessions, update incrementally in O(ΔL) per turn, and answer structured multi-head epistemic probes with zero autoregressive token decoding.
1. Backbone Arena & Weight Surgery (Measured)
Before training anything, I benchmarked four sub-1B candidates head-to-head on NVIDIA A100-SXM4-40GB (1,352 GB/s, 227.7 TFLOPS BF16 measured) and Apple M5 16 GB Metal (78.0 GB/s, 9.77 TFLOPS FP16 measured, mlx 0.32.4), using sandwiched control → candidate → control runs (≥ 6 samples per arm, control drift ≤ 0.16%) and true GPU allocator residency (mx.get_active_memory() and torch.cuda.memory_allocated()).
Starting from Apache-2.0 Qwen/Qwen3.5-0.8B, I stripped the unused vision tower and multi-token prediction modules (873.4M → 752.4M text parameters, verified max |Δlogit| = 0.000000 exact parity). That leaves a 3:1 hybrid stack: 18 Gated DeltaNet linear-recurrent layers (constant 18.6 MiB state at any sequence length) interleaved with only 6 GQA full-attention layers (256K native context):
| Backbone | Params | Layer Split | M5 Metal @ 64K | M5 Metal @ 128K | 64K / 128K Trajectory Recall |
|---|---|---|---|---|---|
Warden-S1-752M (Q4) |
752M | 18 DeltaNet + 6 GQA | 831.1 MiB (Q8 KV) | 855.3 MiB (Q4 KV) | PASS (exact 128K secret match) |
Qwen3-0.6B (YaRN, Q4) |
599M | 28 Full GQA | 2,606 MiB (Q4 KV) | 4,414 MiB (Q4 KV) | FAIL (2.5×-14× over 1 GiB cap) |
Falcon-H1-0.5B (Q4) |
522M | 36 Mamba-2 + GQA | 945 MiB (Q8 KV) | 981 MiB (Q4 KV) | FAIL (0/4 recall; 688.7s prefill) |
LFM2-700M (Q4) |
743M | 10 Short-Conv + 6 GQA | 854 MiB (Q8 KV) | 878 MiB (Q4 KV) | FAIL (negative log-prob margin) |
831.1 MiB at 64K (Q8 KV) and 855.3 MiB at 128K (Q4 KV), strictly below the 1,024 MiB cap.2. O(ΔL) Turn-Delta Latency & Multi-Head Probing (Measured)
Because a coding session grows turn by turn, Warden-S1 caches the 18.6 MiB Gated DeltaNet state alongside the 6-layer GQA KV cache and processes only the newly appended turn:
18.76×warm turn speedup on Apple M5 Metal:1.59 swarm (60Kcached +2Kturn delta) vs30.4 scold62Kprefill.18.92×warm turn speedup on NVIDIA A100:157.6 mswarm vs2,981 mscold62Kprefill.- Parallel multi-question probing (
K = 32): Evaluates 32 structured epistemic probes against a frozen64Ksession in15.32 ms/probe(5.41×batch speedup) across five heads (noul,choice,score,locusspan pointer, andsaliencecompaction scorer) with0.0cross-question state leak.
O(ΔL) turn-delta latency (control → candidate → control, 6 samples/arm, all control drifts ≤ 0.16%).3. WardenS1-Bench, Stage 3.5 Curriculum & Cross-Platform ONNX-Int4
To train and evaluate long-horizon judgment rather than toy snippet classification, I built WardenS1-Bench: 4,200 trajectories (225,650,644 exact tokens, 47.14% spanning 50K-128K tokens), 67,200 probes across six operational failure classes, and 2,100 counterfactual twin pairs (minimal trajectory edits that flip ground-truth verdicts to penalize shortcut heuristics) with fork-clustered deduplication enforcing 0 repository overlap across splits.
Stage 3.5 polishes the 4K → 48K → 128K curriculum with a 50/50 replay mix of zero-leakage <4K single-edit, oscillation, and pre-stop JSON states (0 SHA-256 and 0 13-gram overlaps across 1,319,494 held-out benchmark 13-grams) and long 4K-128K counterfactual twin trajectories, followed by post-hoc temperature calibration:
| Model / Checkpoint | Weights | Noul AUROC (All / 80K-128K) | Noul ECE | Choice F1 | Score ρ | CF Net Flip | Locus Top-1 |
|---|---|---|---|---|---|---|---|
Warden-S1-752M (Stage 3.5 BF16 Cal) |
1,458 MiB | 0.9964 / 0.9988 | 0.0126 | 0.8726 | 0.8784 | 0.9174 | 0.9219 |
Warden-S1-752M-MLX-Q4 (Stage 3.5 M5) |
415.5 MiB | 0.9957 / 0.9947 | 0.0175 | 0.8726 | 0.8814 | 0.9115 | 0.9297 |
Warden-S1-752M-ONNX-Int4 (Browser/CPU/CUDA) |
461.3 MiB | 0.9923 (36-state parity) | 0.0324 | 0.7846 (1.0000 BF16 agree) | 0.8927 | 0.9259 | 0.9167 (97.2% agree) |
Warden-S1-752M (No-CF Ablation) |
1,458 MiB | 0.9801 / 0.9825 | 0.0096 | 0.6174 | 0.7302 | 0.7507 | 0.6265 |
Zero-shot Qwen3-1.7B |
3,440 MiB | 0.6492 / 0.6845 | 0.0754 | 0.3827 | 0.0000 | 0.2191 | 0.0733 |
Zero-shot Qwen3.5-0.8B |
1,665 MiB | 0.5663 / 0.4881 | 0.3451 | 0.1465 | 0.0000 | 0.0059 | 0.0455 |
On Apple M5 Metal, Stage 3.5 Warden-S1-752M-MLX-Q4 (415.50 MiB on disk) holds live steady residency at 842.91 MiB @ 64K (Q8 KV) and 867.43 MiB @ 128K (Q4 KV) with 0.9998 Salience AUROC, 0.0208 Abstention MAE, and tight BF16 validation parity (0.00271 overall mean probability delta, 0.0183 Noul delta, 0.9844 Locus Top-1 agreement). Beyond Apple Silicon, the 461.3 MiB sharded ONNX-Int4 package runs with 0 PyTorch runtime across browsers (onnxruntime-web WebGPU/WASM via warden_s1_web.js), Linux/macOS/Windows CPU, and CUDA GPUs, with all six shards under 92 MiB, 0 forbidden WebGPU control-flow ops, and deterministic O(ΔL) state equivalence (max |Δprob| = 6.85e-7 in Node CPU).
WardenS1-Bench robustness from 4K to 128K tokens: Warden-S1-752M-MLX-Q4 (415.5 MiB) holds 0.9957 Noul AUROC (0.9947 at 80K-128K), 0.9297 Locus Top-1 recall, and 0.9998 Salience AUROC with near-zero quantization drift vs. BF16.
Action Guard, Done Verify, Repo Rules, S1 General, Taint Guard, and Trajectory Health.
0.0126 BF16 / 0.0175 MLX-Q4 ECE) and epistemic abstention distribution on unanswerable probes centered tightly at p = 0.50 (right, 0.0208 MAE).4. 10-Session < 1 GiB Multiplexing & Live 100K+ Agent Runs
To verify real multi-project daily workloads, I ran Stage 3.5 Warden-S1-752M-MLX-Q4 behind a local TypeSafe-compatible loopback daemon across two live tests:
- 10 simultaneous
64K-98Ksessions (6 × 64KQ8 KV +2 × 80KQ4 KV +2 × 98KQ4 KV): Peak Apple M5 Metal active residency stayed at858.33 MiB(165.67 MiBheadroom under1,024 MiB), hitting20/20(100%) concurrent delta cache hits,22/22BPE boundary-healed prefix matches, and3.13×zstd L3 cold-wake compression (341.69 MiB → 109.01 MiBat98Ktokens,2/2cold-wake delta hits). - Fast L2 RAM Paging (
2,344 ms → 104.4 ms,22.5×faster) & 2-Token BPE Boundary Healing: Replacing naive numpy state copies + allocator flushes cut L2 swap p50 from2,344 msto104.39 ms(22.5×faster; contiguous host-RAM slab work targets< 50 ms), while checkpointing state2tokens before each turn boundary (len(ids) - 2) eliminated exact-prefix misses whenever a new turn's leading\nmerged into\n\n. - Persistent
100K+-token RPC trajectory verification (Haiku 5.5,Sonnet 5.5,Opus 5.5): Sustained96.3%-97.0%steady KV cache-read hit rates through104.5K-130.8Ktokens (0protocol errors at$0.00GPU cost, preventing an unhintedR3:never-clip-user-textescape introduced by the unguarded Haiku control arm).
100K+ RPC session KV cache-read stability (left) and 10-session concurrent 64K-98K Apple M5 Metal residency peaking at 858.33 MiB with 20/20 BPE-healed delta hits and 104.4 ms p50 L2 swaps (right).5. 100-Request Stratified Head-to-Head vs. Cloud Jev & OOD Benches
I benchmarked Stage 3.5 local Warden-S1-752M-MLX-Q4 (415.5 MiB) head-to-head against commercial Cloud Jev (jev-latest) across 100 stratified HTTP requests (72 long-context WardenS1-Bench states across all 6 domains and 4K-128K buckets, plus 28 short <4K pi-warden static judge-bench and rules-bench cases; rescored with 0 new Cloud Jev calls):
| Metric | Warden-S1-MLX-Q4 (Matched n=66) |
Cloud Jev (Matched n=66) |
Warden-S1 All 100 Reqs |
|---|---|---|---|
| Request Acceptance / Ceiling | 66/66 (100%) | 66/100 (66%; 34% HTTP 400 >33K tok) | 100/100 (100%) up to 117,899 tok |
| Noul Accuracy (95% CI) | 96.1% [94.1, 97.9] | 84.9% [80.4, 88.7] | 96.9% [95.5, 98.2] |
| Noul AUROC (95% CI) | 0.9933 [0.9864, 0.9987] | 0.9449 [0.9225, 0.9661] | 0.9949 [0.9911, 0.9982] |
| Noul Brier / ECE | 0.0270 / 0.0269 | 0.0998 / 0.0734 | 0.0232 / 0.0195 |
| Choice Accuracy / Macro-F1 | 84.3% / 0.7797 | 88.6% / 0.7995 | 87.7% / 0.8077 |
| Score Spearman ρ / MAE | 0.9161 / 0.0511 | 0.6636 / 0.2312 | 0.9160 / 0.0531 |
| Abstention MAE / Overconf. | 0.0213 / 0.0% | 0.4664 / 100.0% | 0.0216 / 0.0% |
| Counterfactual Flip / Stability | 95.7% / 99.1% | 47.8% / 86.1% | 92.9% / 99.0% |
| API Cost (100 requests) | $0.00 (3.24M local tok) | $0.0276 (657.9K accepted tok) | $0.00 |
Jev: Stage 3.5 Warden-S1 accepts 100% of requests up to 117K tokens (where Cloud Jev rejects all 50K-128K payloads) and leads on matched Noul AUROC (0.9933 vs. 0.9449), Brier (0.027 vs. 0.100), abstention, and counterfactual sensitivity.Stage 3.5 out-of-distribution pi-warden static benchmark gains (zero benchmark overlap, $0.00 local loopback):
<4Khead-to-head slice (n=28): Noul AUROC rose from0.5231(Stage 2) to0.6872overall, hitting1.0000onjudge_bench_stuckand0.7755onrules_bench.judge-bench(80cases,240requests):stuckaccuracy improved from50%(Brier0.48) to85.0%-87.5%(Arm A85.0%at100%precision, Brier0.128; Arm C87.5%at100%recall, Brier0.121), whiledonerecall climbed from10%-35%to75.0%-80.0%.rules-bench(161cases,147scored): Recall@0.5 jumped from5.4%to41.9%(7.75×Stage 2,83.8%precision,8.2%FPR), and Recall@0.7 rose from5.4%to23.0%(85.0%precision,4.1%FPR).
6. Open-Weight Release, Dataset & Citation (Apache-2.0)
- Apple Silicon 4-Bit MLX (
415.5 MiB):DevMortimer/Warden-S1-752M-MLX-4bit(< 1 GiBacross 10 concurrent64K-98Ksessions) - Browser WebGPU, Node, Linux & Windows Int4 (
461.3 MiB):DevMortimer/Warden-S1-752M-ONNX-Int4(zero PyTorch runtime, 6 shards≤ 92 MiB) - Full-Precision Reference Weights (
BF16):DevMortimer/Warden-S1-752M - Benchmark & Training Corpus (
225.7Mtokens):DevMortimer/WardenS1-Bench(4,200trajectories,67,200probes,2,100counterfactual twin pairs) - Technical Paper: Download PDF · Zenodo DOI: 10.5281/zenodo.24494405
- Integrations & Eval Archive:
pi-warden(Stage 3.5 eval archive) andpi-typesafe