{
  "id": 450406,
  "title": "How to Build a Production Agent Harness",
  "url": "https://urgent.news/2026/08/10/how-to-build-a-production-agent-harness",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-10T08:25:11.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/hackmamba/how-to-build-a-production-agent-harness-4k7o"
  },
  "original_language": "en",
  "account": "Build the Context Component\nThe context component prepares a structured representation of your project's components and their relationships before the agent begins executing. This prevents the agent from having to manually track dependencies, which can lead to errors and inconsistencies. Open the agent-harness/harness/context/context.ts file created by bit create module and replace its contents with the following code:\n\n```typescript\nimport { readJsonSync, writeJsonSync } from 'fs';\nimport { resolve } from 'path';\n\ntype Dependencies = {\n[name: string]: string;\n};\n\nexport type Context = {\ncomponents: Dependencies;\n};\n\nconst DEFAULT_CONTEXT: Context = {\ncomponents: {},\n};\n\nexport function loadContext(componentPath = './components.json'): Context {\nconst abs = resolve(componentPath);\nif (!existsSync(abs)) return DEFAULT_CONTEXT;\nconst raw = readJsonSync(abs);\nreturn { ...DEFAULT_CONTEXT, components: raw };\n}\n\nexport function saveContext(context: Context, componentPath = './components.json') {\nwriteJsonSync(componentPath, context);\n}\n```\n\nThis code defines a Context interface and provides functions to load and save the context to a JSON file. The loadContext function reads the components.json file, merging any existing data with the default settings. The saveContext function writes the updated context back to the same file.\n\nBuild the Verifier Component\nThe verifier component checks the agent's output against a set of criteria before proceeding to the next step in the loop. This ensures that the agent's results meet the desired outcome. Open the agent-harness/harness/verifier/verifier.ts file and replace its contents with this code:\n\n```typescript\nexport type Verdict = 'NO' | 'YES' | 'MAYBE' | 'IFF';\n\nexport function verify(output: string, doneCondition: string): Verdict {\nif (output === doneCondition) return 'YES';\nif (output === '') return 'NO';\nreturn 'MAYBE';\n}\n```\n\nThis verifier function takes the agent's output and a done condition as parameters. It returns a verdict based on whether the output matches the done condition exactly, is empty, or neither.\n\nComplete the Harness\nTo use the three components together in your agent project, run the following command:\n\n```bash\nbit install @your-username/agent-harness.harness.state @your-username/agent-harness.harness.context @your-username/agent-harness.harness.verifier\n```\n\nThis command installs all three components from your shared scope into your agent project. You can now use the harness.state, harness.context, and harness.verifier components in your agent's codebase. The harness will help maintain consistent state tracking, proper context loading, and accurate output verification, leading to more reliable and maintainable AI agents.",
  "summary": "AI agents don't usually become unreliable all at once. They degrade quietly. One session the agent repeats a step it already completed. The next, it loses track of where it was mid-run and starts over from scratch. Eventually it produces output with nothing in place to verify whether it actually succeeded. The problem is structural. Harness components get built as one-off scripts instead of…",
  "key_points": [
    "Context component prepares project components and relationships",
    "Verifier component checks agent output against done condition",
    "Install harness components using bit install command"
  ],
  "editors_take": "This development enables more reliable and maintainable AI agents by providing a structured framework for state tracking, context loading, and output verification, reducing errors and inconsistencies.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}