Urgent.News

the world's headlines, one feed

Editions

Tech

How to Build a Production Agent Harness

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…

Build the Context Component

The 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:

```typescript

import { readJsonSync, writeJsonSync } from 'fs';

import { resolve } from 'path';

type Dependencies = {

[name: string]: string;

};

export type Context = {

components: Dependencies;

};

const DEFAULT_CONTEXT: Context = {

components: {},

};

export function loadContext(componentPath = './components.json'): Context {

const abs = resolve(componentPath);

if (!existsSync(abs)) return DEFAULT_CONTEXT;

const raw = readJsonSync(abs);

return { ...DEFAULT_CONTEXT, components: raw };

}

export function saveContext(context: Context, componentPath = './components.json') {

writeJsonSync(componentPath, context);

}

```

This 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.

Build the Verifier Component

The 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:

```typescript

export type Verdict = 'NO' | 'YES' | 'MAYBE' | 'IFF';

export function verify(output: string, doneCondition: string): Verdict {

if (output === doneCondition) return 'YES';

if (output === '') return 'NO';

return 'MAYBE';

}

```

This 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.

Complete the Harness

To use the three components together in your agent project, run the following command:

```bash

bit install @your-username/agent-harness.harness.state @your-username/agent-harness.harness.context @your-username/agent-harness.harness.verifier

```

This 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.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — it may contain errors, so check the original before relying on it.

Read the original at dev.to →

More in Tech

Basant 2027 Dates Confirmed

Basant 2027 Dates Confirmed

Punjab is set to celebrate Basant 2027 in January, with the festival expected to be held before the start of … Read More The post Basant 2027 Dates Confirmed appeared first on ProPakistani .

Zero-Knowledge Age Verification on Midnight: How Compact Enables Private On-Chain Data

How do you verify user eligibility on-chain without revealing sensitive personal identity data? Traditional KYC processes force an unwanted trade-off: transparency versus privacy.

  • Midnight Network separates public and private states on-chain.
  • Compact language simplifies zero-knowledge logic creation.
  • AgeVerification contract updates verification status locally.

OpenCode Session Framework Internals

The easiest way to misunderstand an agent session is to treat it as a chat API call with a longer memory. Send a prompt, receive a response, append both to a transcript. That is enough for a demo.