Open Harness
Learn

Quickstart

Run your first reactive agent in 5 minutes

Quickstart

This guide will get you running a reactive agent in under 5 minutes.

Prerequisites

  • Bun installed
  • Claude Code subscription (for auth) or Anthropic API key

Installation

Create a new project and install Open Harness:

mkdir my-agent && cd my-agent
bun init -y
bun add @open-harness/core

Your First Agent

Create index.ts:

import { createWorkflow, ClaudeHarness } from "@open-harness/core";

// 1. Define your state type
type State = {
  topic: string;
  summary: string | null;
};

// 2. Create a typed workflow factory
const { agent, runReactive } = createWorkflow<State>();

// 3. Define a reactive agent
const summarizer = agent({
  prompt: `Summarize this topic in 2-3 sentences: {{ state.topic }}`,
  activateOn: ["workflow:start"],
  emits: ["summary:complete"],
  updates: "summary",
});

// 4. Run the workflow
async function main() {
  const harness = new ClaudeHarness({
    model: "claude-sonnet-4-20250514",
  });

  const result = await runReactive({
    agents: { summarizer },
    state: {
      topic: "The history of artificial intelligence",
      summary: null,
    },
    harness,
    endWhen: (s) => s.summary !== null,
  });

  console.log("Summary:", result.state.summary);
  console.log("Duration:", result.metrics.durationMs, "ms");
}

main();

Run It

bun run index.ts

You should see output like:

Summary: Artificial intelligence research began in the 1950s with pioneers like Alan Turing...
Duration: 1234 ms

What Just Happened?

Let's break down the signal flow:

  1. workflow:start - The workflow emits a start signal
  2. Agent activates - Summarizer subscribes to workflow:start
  3. Harness runs - Claude generates the summary
  4. State updates - updates: "summary" writes the output to state
  5. Workflow ends - endWhen condition is satisfied

Key Concepts

Signal Subscription

Agents declare what signals they react to:

activateOn: ["workflow:start"]  // React to workflow lifecycle
activateOn: ["analysis:done"]   // React to custom signals

State Updates

The updates field automatically writes agent output to state:

updates: "summary"  // output → state.summary

Termination

endWhen defines when the workflow completes:

endWhen: (state) => state.summary !== null

Are you stuck?

Error: Cannot find module '@open-harness/core' Run bun install to install dependencies.

Error: Authentication failed Open Harness uses Claude Code subscription authentication. Make sure you're running from within Claude Code.

Next Steps

On this page