Building the runtime
Compile, gateway, Critic, evaluators, failure handling — the per-request pipeline.
Build the Context Pack Compiler: Eight Stages, Eight Files
The first compile function we wrote was 600 lines, four mixed concerns, and a dozen places to add a bucket. Eight stages and eight short files later, the compile is something one engineer can hold in their head in an afternoon. Here is each stage as code, with what enters and what leaves.
Build the Tool Gateway: The Boundary That Actually Stops a Bad Action
The Tool Gateway is the only path to external effect, which means it is the only place a destructive call can be stopped before it happens. Most stacks treat it as glue. Here is the resolver, the typed envelopes, and the destructive-path handshake — code you can paste in today.
The Critic: verify, score, consolidate — in 80 Lines
The Planner is creative. The Executor is mechanical. The Critic is the part that says 'no' or 'yes, with caveats'. Most agent stacks ship without one, which means the Planner's output is also the verdict. Here is the Critic as three small functions and one typed report — concrete enough to wire into the loop today.
Wiring the Five Evaluators: Policy, Utility, Latency, Safety, Cost
Five evaluators is not a slogan — it is the smallest set that catches the failure modes that actually ship to production. Here is each one as TypeScript you can paste into your harness today, plus the scorecard envelope they emit and the release gate that consumes it.
Failure Playbooks: The Typed Verdict Map
When a tool call fails, the right next action depends on what kind of failure it was. Most stacks have one retry-with-backoff loop and call that 'failure handling'. The harness's job is to be specific — typed verdicts, dispatched to typed compensations, with a reversal-token check before any compensating write.