HARNESS LAB

STAGE 12 · PORTFOLIO

Harness Lab

Twelve working prototypes from the agentic AI engineering roadmap. The harness is real; the model is simulated.

Stages you open get a visited marker, stored only in this browser.

S1

Context Assembler

Token budgets, greedy packing, and overflow you can watch happen.

Practice build visited
S2

Durable Workflow

Six steps, checkpoints in localStorage, crash it and resume it.

Practice build visited
S3

MCP From Scratch

A real JSON-RPC 2.0 server in the page, plus its stdio twin.

Practice build visited
S4

Triage Router

Confidence scoring routes cheap or heavy, with the savings tallied live.

Practice build visited
S5

Agentic RAG

Hybrid search, grading, query rewrite, and honest abstention.

Practice build visited
S6

Memory Engine

Working, episodic, and semantic tiers with scored eviction.

Practice build visited
S7

Trajectory Eval Gate

Golden trajectories, mutated agents, and a gate that blocks bad runs.

Practice build visited
S8

Security Middleware

PII tokenization, injection sanitizing, and scope checks.

Practice build visited
S9

Voice Agent

Token streaming, a parallel tool call, and a measured interrupt.

Practice build visited
S10

DPO Flywheel

Thumbs down becomes pairs, pairs become a nightly training job.

Practice build visited
S11

FinOps Middleware

Per-step budget projection, an instant halt, and semantic cache hits.

Practice build visited
S12

Portfolio and Teardowns

This page: the write-ups, the decisions, and the system map.

you are here

Three teardowns

The builds above are demos. These are the arguments they make, written the way I would defend them in a design review.

1. Cutting inference cost 94% with a triage router

The router reads four cheap features off every incoming request and scores its own confidence before any model runs. Routine requests take the fast path at $0.002 each. Only the ones the scorer cannot vouch for escalate to the heavy path at $0.06, and the escalation log names the exact feature that sank each one.

At a 3 percent escalation rate the blended cost lands near $0.0037 per request, a 94 percent cut against sending everything to the heavy model, and p50 latency stays at fast-path speed because 97 percent of traffic never queues for the big model. The knob that matters is the threshold, and Stage 4 lets you drag it and watch escalation, savings, and latency move against each other in real time.

BLENDED COST
$0.0037 / req
ALL-HEAVY BASELINE
$0.0600 / req
ESCALATION RATE
3%
FAST-PATH P50
300 ms

2. Memory that evicts before it hallucinates

The memory engine keeps three tiers with hard caps, because an agent that remembers everything eventually retrieves the wrong thing with total confidence. Raw turns live in working memory. Once that tier overflows, the oldest turns are compressed extractively into a single episodic summary, keeping the sentences that carry numbers, names, and decisions.

Episodic entries carry a score, half recency, part relevance, part importance, and when that tier overflows the lowest score is evicted and the eviction is logged with its score attached. Facts graduate to the semantic tier and are deduped there, so what survives is small, current, and auditable. Stage 6 fast-forwards 30 turns through the whole machine so you can watch every compression and eviction happen.

WORKING TIER CAP
8 turns
EPISODIC TIER CAP
6 summaries
COMPRESSION KEEPS
Numbers, names, decisions
EVICTIONS LOGGED
100%, with scores

3. The eval gate that caught a rogue refund

A refund agent produced a trajectory that looked fine in the transcript and was wrong in the tool calls: it skipped the policy check and issued the refund anyway. The gate compares every run against the golden trajectory step by step, tool name, arguments, and order, and a calibrated rubric scores each step on the way through.

Any deviation blocks the run with the offending step highlighted, and once a baseline and a variant have both run, their diff sits side by side. In Stage 7 the mutated agent tries three rogues, an unapproved external email, a wrong refund amount, and a skipped policy check, and the gate catches all three.

GOLDEN PATH
4 steps
MUTATIONS CAUGHT
3 of 3
RUBRIC PASS BAR
0.80
BLOCKED RUNS SHIPPED
0

Architecture decision records

Five decisions the whole lab is built on. Each stage page is one of these, made executable.

ADR-001Harness over prompts

Behavior lives in typed, testable harness code. Prompts are data the harness assembles at runtime, not the place where logic hides and rots.

ADR-002Checkpoints over retries

Every workflow step writes a checkpoint before it acts, so a crash resumes from durable state instead of replaying side effects and hoping they are idempotent.

ADR-003Tokens over raw PII

Models see vault tokens, never raw personal data. Rehydration happens at the edge, after the model answers, inside the trust boundary.

ADR-004Budgets as code

Spend limits are middleware with a projection formula and a hard halt, enforced before each step, not a dashboard somebody checks on Friday.

ADR-005Trajectories as the unit of accountability

We grade the sequence of tool calls, not the final paragraph. A pretty answer produced by a rogue trajectory is a failing run.

System diagram

How the twelve stages compose into one platform. Requests flow left to right; the harness in the middle owns state, budgets, and the grade.

UI Router Harness Tools / MCP JSON-RPC Memory Evals FinOps requests scored calls store recall trajectories halt signal cost tally

The Router scores before anything expensive runs. The Harness holds the workflow state, calls Tools over MCP, reads and writes Memory, emits trajectories to Evals, and answers to FinOps, which can halt a run mid-flight when the budget projection says so.

What this proves