Build and operate AI agents in one language.
Harn is a pipeline-oriented language for AI agents. LLM calls, tools, capability checks, durable steps, and deterministic replay are language and standard-library features, not SDKs you wire together yourself.
pipeline review(task) {
let files = ["src/main.rs", "src/lib.rs"]
let reviews = parallel each files { file ->
let code = harness.fs.read_text(file)
retry 3 {
llm_call(code, "Review this Rust file and list any issues.")
}
}
for review in reviews {
log(review)
}
}call_closure, a missing bounds check, and one stale doc snippet.- Open source, written in Rust
- Deterministic replay
- Capability-safe by default
- Speaks MCP, ACP & A2A
Runnable examples with real receipts
The same checked scenario files ship in the CLI demo bundle and run locally with deterministic fixtures.
Review a pull request and return a verdict.
A reviewer persona scans the diff, asks one clarifying question, then returns a structured verdict with reasoning and a cost rollup. It runs fully offline against a recorded tape.
This scenario ships more than one file. The prompts live in sibling .harn.prompt templates and load with render_prompt, the way a real Harn project is laid out.
fn diff_summary() {
return {
repo: "burin-labs/widgets",
pr_number: 502,
files: [
{path: "src/retry.ts", loc_added: 86, loc_removed: 12, risk: "high"},
{path: "src/retry.test.ts", loc_added: 124, loc_removed: 0, risk: "low"},
{path: "src/http.ts", loc_added: 14, loc_removed: 8, risk: "medium"},
{path: "docs/retry.md", loc_added: 38, loc_removed: 0, risk: "low"},
{path: "package.json", loc_added: 1, loc_removed: 1, risk: "medium"},
],
}
}
fn total_added(files) {
let total = 0
for f in files {
total = total + f.loc_added
}
return total
}
fn render_review_prompt(diff) {
return render_prompt(
"review.harn.prompt",
{
pr: diff.pr_number,
file_count: len(diff.files),
files: diff.files,
total_added: total_added(diff.files),
},
)
}
fn render_clarification_prompt(pr, answer) {
return render_prompt("clarification.harn.prompt", {pr: pr, answer: answer})
}
pipeline default(_task) {
const diff = diff_summary()
const system = "You are review_captain, a thorough code reviewer."
const review_prompt = render_review_prompt(diff)
const initial_envelope = llm_call(review_prompt, system)
__io_println("=== review_captain · stage 1 (initial scan) ===")
__io_println(initial_envelope.text)
__io_println("")
const author_answer =
"Yes, the retry middleware is intended to wrap idempotent requests only; non-idempotent calls bypass it via the `safe: false` opt-out."
const clarification_prompt = render_clarification_prompt(diff.pr_number, author_answer)
const final_envelope = llm_call(clarification_prompt, system)
const receipt = {
persona: "review_captain",
execution_mode: "advisory",
approval_required: false,
repo: diff.repo,
pr_number: diff.pr_number,
files_reviewed: len(diff.files),
clarifying_question_asked: true,
clarifying_question_answer: author_answer,
final_verdict: final_envelope.text,
receipt_kind: "review_receipt",
}
__io_println("=== review_captain · stage 2 (final verdict) ===")
__io_println(json_stringify(receipt))
return receipt
}The agent runtime, built into the language
Orchestration, safety, and observability are primitives in Harn and its standard library, so they compose instead of fighting each other.
Pipelines are first-class
Compose work with the |> operator. Data and control flow read top to bottom, and the compiler tracks the shape of every stage.
LLMs and tools, built in
llm_call, agent_loop, tool vaults, MCP, reranking, and ensembles are language primitives, not a bolt-on SDK you assemble by hand.
Compile-time capability safety
Filesystem, network, and process access are capabilities checked before a single line runs. No surprise side effects inside an autonomous loop.
Deterministic replay
Every run records and replays. Step back through an agent's decisions, diff two runs, and debug non-determinism out of the system.
Durable steps and triggers
Checkpoint long-running work and resume after a crash. Fire pipelines from cron, webhooks, GitHub, Slack, and more.
Protocols, natively
Speak MCP, ACP, and A2A out of the box. Embed Harn in Rust, or run it as a server with harn serve.
Find your path
The documentation follows Diátaxis, organized around what you are trying to do.
Learn by building
Start from zero and build a working agent, MCP server, or eval pipeline step by step.
ExploreGet a task done
Recipes for the things you actually need: hooks, channels, pools, refactors, and more.
ExploreLook up the details
The complete language, runtime, standard-library, protocol, and CLI reference.
ExploreUnderstand the design
The reasoning behind the host boundary, sandboxing, and Harn's architectural decisions.
ExploreWrite your first pipeline
Install the CLI, write a few lines of Harn, and run a real agent in minutes.