Production Agent Architecture

The Harness
Determines
Agent Success

Reference architecture patterns for production AI agent systems. Not better models. Better engineering discipline: context architecture, execution guardrails, and memory infrastructure that actually works.

Architecture Readiness

0%
Harness Gain +26%
Zero Model Changes 52.8 → 66.5%
Enterprise Fail Rate 70-95%
Planning Ratio 85% Plan / 15% Code
System Architecture

Terraphim Engine Architecture

Document input flows through the Aho-Corasick engine to a knowledge graph, filtered by role, and dispatched to hook, REST, or WASM runtime targets.

DOCUMENT INPUT AHO-CORASICK ENGINE O(n) MULTI-PATTERN KNOWLEDGE GRAPH NODES + EDGES HOOK SYSTEM EDITOR / CLI REST API HTTP SERVICE WASM RUNTIME BROWSER / EDGE LOCAL STORE ON-DEVICE ONLY ROLE FILTER PERSONA WEIGHT TEXT IN MATCH OUT OUT OUT
Harness Engineering

Three Jobs of an Agent Harness

The harness, not the model, determines agent success. LangChain's coding agent jumped from 52.8% to 66.5% on Terminal Bench 2.0 by changing zero model parameters.

JOB-001

Context Architecture

Deciding what information the model sees at each step. Context is a scarce resource: a 1M token window with 800K of noise performs worse than 200K with 150K curated signal. Structured compaction before the window fills.

JOB-002

Execution Guardrails

Enforcing what the model can and cannot do. Risk-tiered CI with machine-readable contracts: high-risk paths get policy gates, browser evidence, and security scans. Low-risk paths get fast-tracked.

JOB-003

Memory Infrastructure

Ensuring the model learns from its own history. Failed commands captured automatically, corrections applied, patterns graduated to rules. Cross-session search prevents repeating solved problems.

Failure Modes

Three Ways 1M Token Windows Fail

Bigger context windows do not solve the problem. They make it worse without proper architecture.

Context Saturation

By 100K tokens, the window is 60% noise: old file reads, superseded search results, abandoned reasoning paths.

Structured compaction before the window fills

Instruction Dilution

System prompt says "use pnpm." CLAUDE.md says "run tests before committing." README says "use npm." By 200K tokens, instructions compete with 150K of history and lose.

Priority-weighted instruction injection

Goal Drift

Long-running agents accumulate so many intermediate steps that they lose sight of the original objective. The model optimises for local coherence rather than global progress.

Periodic reality-check prompts and drift detection
Honest Comparison

What You Keep vs What They Take

Framework sprawl versus disciplined harness engineering.

CapabilityReference ArchitectureFramework + CloudRaw LLM API
Context compaction
Risk-tiered CI gates
Cross-session learning
Role-based knowledge graphs
Multi-agent coordination
Strategic drift detection
Data stays local
Vendor lock-in

Full support   Partial   Not available