Harness Engineering

The infrastructure that turns models into a reliable workforce.

An agent without a harness is a demo. What separates 'the model gave a pretty answer' from 'the system worked all night on its own and I just checked in the morning' is the harness: safety guards enforced in code, evals that block regressions, an audit log of every decision, circuit breakers, token economy treated as a feature. It's the least glamorous part of the AI stack — and the part I most love building.

PreToolUse Hooks Tier Safety (green · yellow · red) Headless Workers Smoke Evals Event-Sourced Audit Circuit Breakers Decision Trace Economy Routing MCP Tools Context Engineering PreToolUse Hooks Tier Safety (green · yellow · red) Headless Workers Smoke Evals Event-Sourced Audit Circuit Breakers Decision Trace Economy Routing MCP Tools Context Engineering
0 Tier-guarded tools in production
0 Coordinated agents in Bailder
0 Evals in the Free Diária showroom
0 Harness risk classes mapped

The harness is the layer between the model and the world: the tools it can call, the permissions on each one, the context that goes in, the cost that comes out, and what happens when something goes wrong. My laboratory is Bailder — an in-house multi-agent orchestrator that runs my real operation over WhatsApp, with 3 coordinated agents, 20+ tools, and headless Claude Code workers that build software in the middle of the night.

Safety, here, doesn't live in the prompt. Every tool call goes through PreToolUse hooks that classify the operation as green, yellow, or red — and red stops everything and demands human confirmation. The same philosophy applies to economy: routing across model tiers has a lock in code that forbids escalating to a more expensive model on retry without approval. I mapped 8 classes of harness risk (from tier-guard tampering to agent-to-agent message loops) before writing the mitigations.

The other half is knowing what the agent did and whether it's still good: an event-sourced audit log, scheduled smoke evals, an eval harness per model tier, 146 evals covering Free Diária's screens — and an observability suite (X-Ray, Decision Trace, replays, brain diff) to answer the question every black box hides: why did the agent do that? When I want to steal a good idea, I reverse-engineer someone else's harness — like the OpenCode deep-dive.

Architecture

Bailder from the inside: an operator on WhatsApp, an orchestrator with a tool loop and MCP, headless Claude Code workers — and, underneath it all, the safety, audit, and eval layer that holds the system when nobody is watching.

Through this lens

Flagship · Multi-Agent · MCP Production · Private

Bailder

Personal multi-agent orchestrator. WhatsApp-native, autonomous Claude Code workers, tier-enforced safety.

Through the harness lens, Bailder is less 'assistant' and more power plant: the question it answers is how to let agents run a real business — deploys, DNS, databases, paid media — without one mistake getting expensive. Every tool has a tier; red stops everything and calls a human. The prompt is never the last line of defense.

Impact
  • PreToolUse hooks classify every tool call as green / yellow / red — in code
  • Red = PendingConfirmation: human in the loop by design, not by promise
  • Headless Claude Code workers inherit the orchestrator's guard
  • Scheduled smoke evals + circuit breakers + event-sourced audit log
Stack
Ruby on Rails 8 Claude Code SDK MCP (Playwright) Multi-LLM (OpenRouter) Solid Queue WhatsApp Cloud API DigitalOcean (auto-deploy)
Observability · Agents Production · Private

Agent X-Ray & Decision Trace

X-ray for production agents. Every decision, every tool call, every deviation — visible and replayable.

Observability is the forgotten half of the harness. This suite exists to make agent behavior genuinely auditable: reconstruct the decision chain tool call by tool call, replay entire sessions, compare behavior across brain versions, and forensically dissect the sessions that went wrong.

Impact
  • Decision Trace: why the agent picked THIS tool with THESE arguments
  • Full session replay — the agent bug becomes a reproducible artifact
  • Brain diff: changed the prompt? Proof of how behavior changed with it
Stack
Ruby on Rails 8 Event Sourcing Hotwire (SSE) Claude Code SDK
Economy · Multi-LLM Production · Private

Economy Routing

Cost routing across model tiers with an escalation lock and an eval harness.

A harness is also economics. This layer routes each task to the cheapest model tier that can handle it — and the most important rule lives in code, not convention: a retry never escalates tier without explicit human approval. Learned the expensive way; today it's a lock.

Impact
  • GLM → Sonnet → Opus routing with an escalation lock in code
  • An eval harness measures whether the cheap tier holds quality before rollout
  • Per-worker-session cost telemetry — economy visible, not estimated
Stack
OpenRouter Multi-LLM (GLM · Claude) Eval Harness Ruby on Rails 8
Agent · QA Active

Fred QA

A WhatsApp agent that runs a testing program with real humans.

A harness isn't just tool guards: it's the whole process with a latch. Fred QA runs a testing program with real humans over WhatsApp — and the fix pipeline it feeds has the rule carved in: auto-merge only on staging; production requires a human panel. An agent with exactly as much autonomy as it should have, never more.

Impact
  • The agent coordinates human testers: recruiting, test scripts, bug collection
  • Auto-merge restricted to staging — production goes through human approval
  • Feedback becomes structured issues with no manual intervention
Stack
Ruby on Rails WhatsApp (Evolution API) Claude Solid Queue
Meta-Orchestration In daily use

MAESTRO

Meta-workflow conducting waves of agents: parallel thinking, serialized writing.

When the work is too big for a single context, the harness becomes orchestration of orchestrators. MAESTRO decomposes the problem into waves: N agents think in parallel, writing is serialized for zero conflicts, and adversarial verification runs between waves. It's how I ship entire features with a fleet of agents.

Impact
  • Waves: parallel thinking, serialized writing — no merge conflicts
  • Adversarial verification between waves kills the plausible-but-wrong finding
  • Dozens of subagents per round, with results aggregated and auditable
Stack
Claude Code (headless) Multi-agent workflows Isolated worktrees
Research · Harness Research

OpenCode Deep-Dive

Reverse-engineering an OSS coding-agent harness — to steal the right ideas.

Serious harness engineering includes studying other people's harnesses. I cloned OpenCode and ran it locally to map the internals — the tree-sitter bash guard, the compaction strategy, the runner lifecycle — and decide with criteria what's worth porting to my own stack instead of reinventing by instinct.

Impact
  • Internals mapped: tree-sitter bash guard, compaction, runners
  • Running locally with OpenRouter to observe real behavior, not read the README
  • Patterns prioritized for porting, with the cost/benefit made explicit
Stack
TypeScript tree-sitter OpenRouter Architecture analysis

The track record, re-read

Aug 2025 – May 2026

Senior Data Migration Engineer · AI-Augmented

Monument (Remote, US)

  • Claude Code as the primary dev driver — in practice, a migration harness: idempotent pipelines were the guard-rail, to-the-cent reconciliation was the eval
  • Multi-level validation (unit, customer, facility, period) as the cutover gate
Claude Code TypeScript Node.js MySQL AWS
May 2023 – Jul 2025

Principal Software Engineer · AI Platform Lead

VIK (Remote)

  • The company's AI platform from zero — where evals, memory, and multi-LLM routing became production requirements, not experiments
  • Company-wide AI-augmented dev adoption: prompting conventions and review of generated code
Ruby on Rails React OpenAI · Claude · Gemini OpenRouter · LiteLLM Kafka · RabbitMQ BigQuery · Looker

The toolkit for this lens

🤖

AI Agent Systems

Multi-agent orchestration in production. Tool-call loops, sub-agents, autonomous Claude Code workers, MCP servers, context engineering.

Multi-Agent Coordination MCP (Model Context Protocol) Function Calling / Tool Use Claude Code SDK Sub-Agents & Hand-offs Context Window Management

AI Safety & Evals

Safety enforced in code, not in the system prompt. Tier-based guards, audit logs, eval gates, circuit breakers, fallbacks.

Tier-Based Tool Guards Eval Frameworks (custom + RAGAS) Audit & Event Sourcing PendingConfirmation Flows Pre-Tool Hooks Smoke Evals on Schedule
🏗

Multi-LLM Orchestration

Routing, fallback, and cost-aware orchestration across providers. Streaming, structured outputs, retries, circuit breakers.

Claude (Sonnet · Opus) GPT-4o / GPT-5 Gemini Flash / Pro Llama · Mistral OpenRouter / LiteLLM SSE Streaming

Need agents that don't need a babysitter?

Harness engineering, agent safety, and eval infra — for teams hiring or companies building agents that have to run on their own and answer for what they did.

SB
Sérgio Brito
Online
👤 About 📚 Projects 💻 GitHub Get in Touch