These are real Orchard programs, drawn from the examples that ship with the runtime. Each one is small, runnable, and shows a different shape of agent. The offline ones use the mock provider, so they need no API key. The rest need only a model key.
A minimal assistant
The smallest useful agent. on message is the interactive handler; gen is one self-contained model call that returns a string. It sees the persona and system prompt only, never history or tools.
#!orchard 3.0
agent Echo {
model { provider: mock, name: "echo" }
on message(text: str) -> str {
return gen "Reply briefly and kindly to: {text}"
}
}Run it with orch run echo.orch -t "hi". Swap the model block for provider: anthropic, name: "claude-sonnet-4-6" and the same agent talks to a real model.
A typed triage agent
The central move of the language: gen as Ticket forces the model to return a value of a type you declared, so the code that follows routes on it with an ordinary match that the checker proves exhaustive. No string parsing of model prose.
#!orchard 3.0
agent Triage {
model { provider: anthropic, name: "claude-sonnet-4-6" }
memory { facts: true }
enum Severity { low, medium, high, critical }
type Ticket {
title: str
severity: Severity
summary: str
}
// A deterministic effect the model (and your code) can call.
tool post_to_slack(channel: str, text: str) -> json {
http.post("https://slack.example/api/post", body: { channel: channel, text: text })
}
skill triage(report: str) -> Ticket {
// 1) constrained extraction, guaranteed a valid Ticket
let t = gen as Ticket "Extract a ticket from this report:\n{report}"
// 2) deterministic routing, exhaustive over Severity
match t.severity {
critical => {
post_to_slack(channel: "#oncall", text: t.title)
remember "last_critical" = t.title
}
high => post_to_slack(channel: "#triage", text: t.title)
_ => {}
}
return t
}
on message(text: str) -> str {
return budget(spend: $0.10, steps: 6) { delegate text }
}
}Run the skill directly with orch run triage.orch --skill triage report="API returns 500 on /login", or chat with it via orch run triage.orch -t "my dashboard is slow".
A tool-using agent
A use line adds a built-in pack of tools. A tool is a deterministic effect you declare; a skill is a model-using procedure exposed to the loop as skill_<name>. delegate hands the goal to the autonomous perceive, think, act loop over those tools and skills.
#!orchard 3.0
agent Aster {
model { provider: anthropic, name: "claude-sonnet-4-6" }
persona {
tone: "warm, encouraging, plain-spoken"
traits: ["helpful", "honest", "curious"]
}
memory {
conversation { enabled: true, window: 40 }
facts: true
}
use calculator
use time
// A pure tool: no shell, no network, just computation over its argument.
tool word_count(text: str) -> int {
return text.split(" ").length
}
skill define(term: str) -> str {
return gen "Define '{term}' in two plain sentences a beginner would understand."
}
on message(text: str) -> str {
return delegate text
}
}Run it with orch run assistant.orch -t "what is 6 times 7, and define a monad". The loop may call calculate, word_count, and skill_define on its own.
A concurrent research agent
Deterministic glue around autonomous spans. One gen splits the topic into angles; each angle runs as its own bounded delegate loop; then a final gen synthesizes. The budget wrapper caps each span, and the with clause restricts which tools it may use. Budgets are shared safely across concurrent spans.
#!orchard 3.0
agent Fern {
model { provider: anthropic, name: "claude-sonnet-4-6" }
use web
memory {
facts: true
semantic {
enabled: true
embeddings { provider: none }
top_k: 5
}
}
policy { max_spend: $1.00, allowed_domains: [] }
skill survey(topic: str) -> str {
let angles = gen as list<str> "Three distinct research angles on: {topic}"
let hs = angles |> map((a) => spawn budget(spend: $0.25, steps: 8) {
delegate "Research this angle and cite sources: {a}" with { tools: [web_search, fetch_page] }
})
let findings = hs |> map(await)
return gen "Synthesize these findings into a cited brief on {topic}:\n{findings}"
}
on message(text: str) -> str {
return delegate text
}
}Run it with orch run researcher.orch --skill survey topic="solid-state batteries". spawn runs each span concurrently and returns a future; await joins it.
A scheduled agent
An on schedule handler runs on a recurring interval under orch serve. There is also on file(path: str) in "./dir", which fires when a file appears in a watched directory. The work inside is the same delegate loop, capped by a budget.
#!orchard 3.0
agent NewsBot {
model { provider: anthropic, name: "claude-sonnet-4-6" }
use web
use files { root: "." }
on schedule(every: 1h) {
let digest = budget(spend: $0.30) {
delegate "Check the RSS feeds, summarize new items, dedupe."
}
append_file(path: "news.md", content: digest)
}
}Start the long-running scheduler with orch serve newsbot.orch. It runs the handler every hour and writes the digest to disk. Unattended runs are bounded by the policy spend cap.
These and more (a shell-gated coding helper, an MCP-backed notes agent, a fully local Ollama agent, and a scripted offline demo) are in the examples directory of the source repository.
