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/coreYour 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.tsYou should see output like:
Summary: Artificial intelligence research began in the 1950s with pioneers like Alan Turing...
Duration: 1234 msWhat Just Happened?
Let's break down the signal flow:
workflow:start- The workflow emits a start signal- Agent activates - Summarizer subscribes to
workflow:start - Harness runs - Claude generates the summary
- State updates -
updates: "summary"writes the output to state - Workflow ends -
endWhencondition 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 signalsState Updates
The updates field automatically writes agent output to state:
updates: "summary" // output → state.summaryTermination
endWhen defines when the workflow completes:
endWhen: (state) => state.summary !== nullAre 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.