Hello World Tutorial#
Build and run your first OSPREY agent in about five minutes, with no containers
and no hardware. The hello-world preset is the smallest deployment that
still shows the whole write-safety chain: the simulator, served in this
process, that answers for the channels of your facility file, eleven safety
and bookkeeping hooks, and a browser interface.
Three osprey commands take you from nothing to a running agent:
osprey init my-first-agent --preset hello-world
cd my-first-agent
osprey build
osprey web
The rest of this tutorial walks that path slowly, because the point is not the
agent — it is the profile.yml you get along the way, which doubles as the
syllabus for everything OSPREY can grow into.
Prerequisites
Required:
Python 3.11+
Claude Code CLI installed
Osprey framework installed (
uv tool install osprey-framework, oruv sync --extra devif working from a clone)ANTHROPIC_API_KEYset in your environment
If you haven’t installed the framework yet, follow the installation guide.
Step 1: Create the Project#
osprey init my-first-agent --preset hello-world
cd my-first-agent
osprey init writes one git repository. Everything the preset configures is
spelled out in files you own — nothing is hidden or inherited:
✓ Created my-first-agent
profile.yml your assistant's settings; edit this
data/ channel lists and facility docs; edit these
.env seeded: ANTHROPIC_API_KEY. Not in git
.env.shared settings shared by every host; your .env wins
README.md what everything here does
The repo has four zones, and knowing which is which is most of what there is to learn about OSPREY’s layout:
Source —
profile.ymlanddata/: yours to edit, kept in git.Secrets —
.env: your API keys. Not in git; rebuilds never touch it.Output —
build/: generated byosprey build. Never edit it; deleting it is safe.State —
var/: the agent’s memory and audit log. Not in git.
Step 2: Read profile.yml — It Is the Curriculum#
Open profile.yml. This one file is the manifest for the whole deployment,
and the preset deliberately leaves most of it unset — because every key it
leaves unset is emitted into your copy as a commented block you can turn on
later. The hello-world preset’s minimalism yields exactly 17 such blocks,
covering everything from a channel database to event dispatch to a virtual
accelerator. Growing this project into a production deployment is, quite
literally, uncommenting one block at a time and rebuilding.
The parts that are set are short. The agent’s capabilities are lists of named artifacts from the OSPREY library — eleven hooks (three of which form the write-safety chain), three rules, and one output style:
hooks:
- error-guidance # Post-error hook that surfaces remediation hints
...
# The next three are the write-safety chain, and no write reaches the control
# system until all three agree. Remove any one of them and `osprey build`
# refuses the render while writes are armed, naming the hook and the server
# whose write tools it guarded. Only a read-only deployment may drop them.
- writes-check # Kill switch: refuse every write to a machine whose writes are off
- approval # Gate hardware-write tool calls on human approval prompt
- limits # Enforce per-channel min/max limits, from data/facility/limits.yaml
build/.claude/hooks/ also holds five helper scripts. The hooks import
them; they are not hooks themselves.
And all remaining configuration lives in the config: block, one dotted key
per line:
config:
# Which control system to talk to. `virtual_accelerator` is the simulator of
# the built facility; `serving: in_process` runs it inside this process — the
# facility's channels, its seeds and scenarios, no hardware and no containers
# — and refuses any address outside the facility. `served` reaches the same
# simulator in its container over Channel Access. The demo
# preset shows the EPICS connector configuration,
# and `osprey config --defaults` lists every shipped connector type.
control_system.type: virtual_accelerator
control_system.connector.virtual_accelerator.serving: in_process
# The FIRST guard in the write-safety chain: while `never`, every hardware
# write is refused before the limits check or the approval prompt is even
# consulted. Set it `asked`, rebuild, and the two hooks below take over.
control_system.writes: never
# ...
# The SECOND guard: every write is checked against the records in
# data/facility/limits.yaml (per-channel min/max and writable flags).
control_system.limits_checking.enabled: true
# ...
# The THIRD guard: a write that passed the master switch and the limits check
# still pauses for a yes/no prompt, unless its slider stands at `allowed`.
# Applied by the approval hook, so it reaches only hook-wired tools;
# everything else is gated by the rendered settings.json permissions.
approval.enabled: true
# ...
That control_system.writes: never line is the one this tutorial
comes back to in Step 7. For everything the profile can hold, see
Build Profiles.
Warning
profile.yml is the only durable edit surface. The build/config.yml
you are about to generate is output — every osprey build wipes and
re-renders it, so an edit made there is lost on the next build (and a
session-start check warns you when the build has gone stale). Make changes
in profile.yml and rebuild.
Step 3: Build It#
osprey build
osprey build takes no arguments: it walks up from wherever you run it to
the nearest profile.yml and renders that repo’s build/ directory —
config.yml, the agent’s .claude/ tree (rules, hooks, settings), the
.mcp.json that wires up the MCP servers the agent can call (the
controls server among them), and a copy of your data/ files. The render is complete and disposable: nothing durable lives
in build/.
Note
The first build may take 1–2 minutes to create a virtual environment and install dependencies. Subsequent builds are near-instant.
Step 4: Launch the Web Terminal#
osprey web
This starts the OSPREY Web Terminal on http://127.0.0.1:10100 — a browser
interface with the agent in a terminal pane on the left and a live workspace
viewer on the right, where plots and other artifacts the agent produces appear.
The command prints a login URL (http://127.0.0.1:10100/?token=…) once, at
startup; opening it sets a session cookie and redirects to the clean address.
The token is the server’s own secret, so treat that URL like a password.
No containers are involved; it is a local process serving your build/.
It refuses to start if there is no build yet, so run osprey build first.
Useful variations: osprey web --port 9000 picks another port,
osprey web --repo ~/my-first-agent serves the deployment from anywhere, and
osprey web stop stops a backgrounded (--detach) instance. See
Web Terminal for the full tour.
Note
Prefer to stay in your terminal? osprey chat starts the same agent
against the same build as a plain CLI session — see
Run the Agent from the Command Line. The remaining steps work
identically there; this tutorial assumes the web terminal.
Step 5: Read Some Channels#
The simulator serves the channels of build/facility.json, which
osprey build writes from data/facility/, inside this process — that is
the whole trick behind a five-minute first session. The session is on the
va target, and the control-target chip in the web terminal’s sidebar reads
“Simulator”. Any other
address is answered with <address> is not a channel of this facility, for
example ANY:RANDOM:NAME is not a channel of this facility. Try:
You: Read channel SR:BEAM:CURRENT
The OSPREY agent calls the channel_read tool on the controls MCP server
and reports back a value with units and a status. The exact wording varies with
the agent’s output style, but it looks roughly like:
SR:BEAM:CURRENT 250.3 mA OK
Reads need no approval — only writes are gated. Ask for several at once:
You: Read SR:BEAM:CURRENT and SR:MAG:QF:01:CURRENT:RB
Historical questions work too — “plot the beam current over the last hour” —
because a mock archiver backs the archiver_read tool with synthetic
history, and the plot lands in the workspace pane beside the terminal.
Step 6: Attempt a Write — and Get Refused#
Now ask for a write:
You: Set SR:MAG:QF:01:CURRENT:SP to 150
The write is refused before it reaches the control system: the agent reports
that writes are disabled in this deployment. The exact wording is the agent’s
own, because the refusal happens a layer below it — with the tier at
never, osprey build renders the write tool into the agent’s denied
permissions, so the tool call is blocked before it even executes.
This is the first of three guards that every write must pass:
Who may write (
writes-checkhook) — the tier keycontrol_system.writesisneverhere, so all writes are refused outright. This is what just fired: the build bakes the tier into the agent’s denied permissions. Once the tier allows writes, the hook asks your login’s write switch for the machine on every call. See Who May Write.Limits (
limitshook) — the value is checked against per-channel bounds and writable flags indata/facility/limits.yaml.Approval (
approvalhook) — at asked, a write that passes both still pauses for your explicit yes/no before anything is executed.
Safety is not optional equipment here: the three hooks are declared in your
profile.yml. Remove any one of them and osprey build refuses the render
while writes are armed, naming the hook and the server whose write tools it
guarded. Only a read-only deployment may drop them.
Step 7: Enable Writes — Tier, Rebuild, Chip#
Writes take two steps: the deployment allows them, then you turn them on.
Open profile.yml, find the config: block from Step 2, and allow writes:
config:
control_system.type: virtual_accelerator
control_system.connector.virtual_accelerator.serving: in_process
control_system.writes: asked # ← was never
Then re-render and relaunch:
osprey build
osprey web
Do not edit build/config.yml instead — that file is generated output,
and your edit would vanish on the next build.
The deployment now may write, but your switch is still off. Click the
control-target chip in the sidebar (● Simulator · writes off) and move the
simulator to asked (The control-target chip). A write asked for
with the switch off is refused with a line telling you to do exactly that.
Step 8: Write with the Guards Watching#
The limits file that ships with this preset, data/facility/limits.yaml,
holds three records: two writable quadrupole setpoints with bounds, and one
read-only measurement. osprey build writes them into the render’s limits
database, build/data/channel_limits.json, which is what the guards read.
With the simulator at asked, all three remaining behaviors are now observable.
A write inside its limits — pauses for your approval:
You: Set SR:MAG:QF:01:CURRENT:SP to 150
150 sits inside the 0–300 range declared for this channel, so the limits check passes and the approval prompt appears in the terminal, naming the channel and value. Approve it, and the simulator accepts the write. At asked, nothing is ever written without this step.
A write outside its limits — blocked:
You: Set SR:MAG:QF:01:CURRENT:SP to 500
500 is above the channel’s maximum of 300, so the write is refused: the
limits hook denies it, and the connector checks the same limits database
once more at execution time — so even an approved write cannot carry an
out-of-range value to the (simulated) hardware. Approval is a gate on writes the
limits allow; it is not a way around them.
A write to a read-only channel — blocked regardless of value:
You: Set SR:BEAM:CURRENT to 1.0
SR:BEAM:CURRENT is a measurement, marked writable: false in the
limits file, so the write is refused whatever the value.
Step 9: Edit the Limits File#
data/facility/limits.yaml is your first editable safety artifact. This is
the shipped file:
# Bundled with OSPREY: the hello_world facility. Delete this line to make the file yours.
# The limits hook checks every write against these records. A channel not
# listed here follows control_system.limits_checking.mode; hello-world runs
# optional, so a channel with no record is written with no limits and listing
# a channel is how you put bounds on it or block it.
#
# A setpoint record with min_value and max_value is writable within them.
# writable: false blocks every write to the channel. confirm: false turns off
# the re-read after a write.
records:
# Focusing quadrupole current: writable, but only within these bounds.
- address: SR:MAG:QF:01:CURRENT:SP
min_value: 0.0
max_value: 300.0
writable: true
# Defocusing quadrupole current: writable, with a tighter ceiling.
- address: SR:MAG:QD:01:CURRENT:SP
min_value: 0.0
max_value: 250.0
writable: true
# Beam current: a measurement, so writes are refused outright.
- address: SR:BEAM:CURRENT
writable: false
osprey build writes one entry per record into
build/data/channel_limits.json, each stating writable and confirm:
{
"_version": "4.0",
"SR:BEAM:CURRENT": {"writable": false, "confirm": true},
"SR:MAG:QD:01:CURRENT:SP": {"min_value": 0.0, "max_value": 250.0, "writable": true, "confirm": true},
"SR:MAG:QF:01:CURRENT:SP": {"min_value": 0.0, "max_value": 300.0, "writable": true, "confirm": true}
}
That file is generated output: edit limits.yaml and rebuild. A profile
that ships its own channel_limits.json stops the build. On a float or int setpoint the
bounds decide, so a record is either bounded or a block: with both
min_value and max_value it is written writable: true and need not
say so, and without both it is written writable: false. writable: true
cannot stand in for the bounds: stating it on a float or int setpoint without
both stops the build. A bool, enum, string or waveform setpoint has no bounds
and is writable only when its record says writable: true. confirm: true, the value a record gets when it does not state
one (a command that states timeout_s gets confirm: false: its status
confirms the write), means every write is checked: the connector reads the
channel back once and compares what it finds with the value that was sent, so a write that did
not land is reported rather than assumed.
Channels not listed here are written with no limits — the preset sets
control_system.limits_checking.mode: optional. Under mode: exclusive
only channels in the limits file can be written. Listing a channel is how you
put bounds on it. Add one record:
- address: SR:MAG:CORR:01:CURRENT:SP
min_value: -5.0
max_value: 5.0
Then osprey build to carry the change into the render, and try writes on
either side of the new bounds. This edit-rebuild-observe loop — in data/
or in profile.yml — is the same loop every real deployment is grown with.
Step 10: Read What the Agent Recorded#
Every prompt, answer, tool call and approval decision of your session went into
the agent record, which osprey web runs as a local process beside the
agent. The preset keeps it on the embedded backend, with no container:
agent_record:
backend: embedded
While osprey web runs, the record answers its read API on
http://127.0.0.1:10053 (deployment.port_base + 53). osprey build minted
an operator login for it into .env.agent-record.login.operator (mode 0600).
List your sessions, then the approval decisions the safety chain made:
LOGIN="$(sed -n 's/^OSPREY_AGENT_RECORD_LOGIN=//p' .env.agent-record.login.operator)"
curl -sS --user "$LOGIN" "http://127.0.0.1:10053/v1/read/list_sessions?limit=5"
curl -sS --user "$LOGIN" "http://127.0.0.1:10053/v1/read/entries?kind=decision&limit=10"
The record keeps an entry for 14 days. Each UTC day that has closed is also
exported, whole, as var/archive/<day>/agent_record/entries.parquet the next
time the record runs: the lasting copy, which outlives that window. This query
counts what each identity wrote, by kind, across every exported day:
-- What the agent recorded, from the record's archive: every closed day the
-- record has exported, counted by who wrote each entry and what kind it is,
-- the most frequent first. Run it from the repo root.
SELECT
identity,
kind,
count(DISTINCT key) AS entries,
min(ts) AS first_seen,
max(ts) AS last_seen
FROM read_parquet('var/archive/*/agent_record/entries.parquet')
GROUP BY identity, kind
ORDER BY entries DESC, identity, kind
Save it as hello-world-tutorial.sql in the repo root and run it from there
with DuckDB, which osprey build installs into the build’s own Python
environment:
build/.venv/bin/python -c "import duckdb; duckdb.sql(open('hello-world-tutorial.sql').read()).show()"
On the first day the archive is still empty, and DuckDB reports that no file matches. See The Agent Record for what the record and its archive hold. The demo preset adds a history page in the browser, described in The history page.
The commands you now know are the complete lifecycle, and they are the same
for a production facility deployment: osprey init once, then edit →
osprey build → osprey up / osprey web forever after.
Next Steps#
You have a working agent, and — more importantly — a profile.yml whose
commented blocks map everything it can become.
The production tutorial: The Demo Deployment builds the
demopreset, which adds natural-language channel finding over a facility knowledge graph, a seeded electronic logbook, a real archive, sub-agents, and operator skills — on the same safety model.How it works: How OSPREY works explains the MCP server architecture, the connector system, and the safety mechanisms in depth.
The profile format: Build Profiles documents every key those 17 commented blocks can hold.
CLI reference: CLI Reference covers all
ospreycommands.
The deployment repo that osprey init created also contains
mcp_servers/example_server/, a small working MCP server; its
example_status tool is one the agent already has. Copying that directory
is the quickest way to start your own. The repo’s README.md has a
“Common questions” section that explains how to add your own server, panel,
or volume.