An office is a small distributed system: agents, the roles they
play, and the connections between them, written in a file called
office.md. This page is an index to everything you use to
build one. The lists were read from DisSysLab 2.0; your own installation
can always print its current lists, and each section says how.
| Resource | What it is |
|---|---|
| Setting up | Before the first class: install, run an office, read it, set up your API key. |
| Micro-course | 29 short screens: messages, LLM and Python agents, contracts, the office file, routers, coordinators, two examples, what to expect of a model, and what DisSysLab checks for you. |
| Getting started | The full guide, with every output: your first office, breaking it five ways, then building one from nothing. |
| Lab 1: the one-dollar Tahoe | Attack a car dealership's chatbot, then build the guardrail that stops it. |
dsl commandEverything is done with one command. dsl <command> --help explains any of them.
| Command | What it does |
|---|---|
| Find things | |
dsl list | The offices that ship with DisSysLab. |
dsl roles | The built-in roles, and what each adds to a message. |
dsl show <name> | Print a built-in role, source or sink in full. |
dsl grammar | The office reference: dsl grammar roles, dsl grammar sources, dsl grammar examples. |
| Make an office | |
dsl init <office> <folder> | Copy a gallery office into a folder of your own. Always work on a copy. |
dsl new, dsl edit | Create or change an office by chatting with Claude (below). |
| Check it, see it, run it | |
dsl check . | Every problem, and advice (notes), without running anything. Check before every run. |
dsl draw . | Every agent and every connection; --mermaid for a diagram. |
dsl run . | Run it. It stops by itself when its sources are done; Ctrl-C stops it sooner. --quiet leaves out the run summary. |
| Other | |
dsl doctor | Check your setup: its first line is the verdict. |
dsl fetch-prices | Download your own daily price history, for mac_speed_suite. |
office.md| Resource | What it is |
|---|---|
dsl grammar | The complete reference: sections, declarations, connections, routers, coordinators, nested offices, drafts, and what dsl check reports. It ships with DisSysLab, so it matches the version you have. |
dsl grammar examples | Four gallery offices explained line by line: returns_desk, room_climate_monitor, situation_room_pro, debate. |
| Sense, think, respond | The shape most offices take: sources sense, agents think, sinks respond. |
An office is agents, the roles they play, and the connections between
them. office.md holds two of those three: who is in the
office, and where each one's messages go. What each agent
does, its role, and the role's contracts, live in its own file
under roles/ (below). So
office.md has just two kinds of line:
name: kind(args) says who is in the office. Under
sources:, where messages come from; under
sinks:, where they end; under agents:, each
worker in between, with the role it plays (Felix: topic_filter)
or the router or coordinator it is (Rex: router(on="on_topic")).
Arguments are written as in a Python call.a -> b says where messages go: every message
a sends, b receives, in the order sent.
Chains (a -> b -> c), fan-in (a, b -> c)
and fan-out (a -> b, c, each getting its own copy) are
shorthand for several such lines.The news filter from the micro-course, whole:
sources: # who is in the office
al_jazeera(max_articles=2)
bbc_world(max_articles=2)
sinks:
console_printer
discard
agents:
Felix: topic_filter # an agent playing the role roles/topic_filter.md
Rex: router(on="on_topic")
connections: # where messages go
al_jazeera, bbc_world -> Felix -> Rex
Rex.yes -> console_printer
Rex.no -> discard
Every agent has one inbox and one outbox, so a -> b never
names them. A dot is needed only where there is a choice: one of a
router's ways out (Rex.yes), or one of a coordinator's
inboxes (Gate.done).
A role is what an agent does: one JSON object in, JSON out. An
annotator adds fields to the message; an author
(kind: author) returns a list of new messages, and the message it
received goes no further. A role is a prompt (.md, carried out by
an LLM) or Python (.py, one class). Its front matter's
in: and out: lines are its
contracts. DisSysLab looks in your office's
roles/ folder first, then in the built-in library.
dsl grammar roles has everything.
| Role | What it adds or does |
|---|---|
deduplicator | Each item once; later items with the same key are dropped. Python, stateful; by= names the key. |
entity_extractor | The people, organisations, places and events named. Adds entities. |
geolocator | Where in the world the item is about. Adds location. |
severity_classifier | CRITICAL, HIGH, MEDIUM or LOW. Adds severity. |
summarizer | One plain sentence. Adds summary. |
topic_tagger | One of eight topics. Adds topic. |
writer | A headline and a short briefing. Adds headline, summary. |
To change a built-in role, dsl show it, copy it into your
roles/ folder under a new name, and edit it there. Every gallery
office has a roles/ folder of its own to learn from.
Write a Python role
walks through one, with tests and state.
| Kind | What it does | See it in |
|---|---|---|
router(on="field") | Sends each message on by the value of one field, with one way out per value: Rex.yes, Rex.no; Rex.otherwise takes the rest. | inbox_sorter, org_news_filter |
synchronizer(on="key") | Waits until a message with the same key has arrived on every inbox, then merges them into one. Inboxes are named in the connections (Eve -> Sync.entities). collect= gathers a variable number instead. | room_climate_monitor, situation_room_pro, debate |
gate | Admits one message from in, then waits for anything on done before admitting the next. One item in progress at a time. | returns_desk, debate |
dsl grammar sources lists every one with its arguments;
SOURCES_AND_SINKS
has each one's message shape and setup, with an example.
| Kind | Built in |
|---|---|
| Files | file_source: a .jsonl or .json file; the stand-in for any real source while you build |
| News and feeds | bbc_world, npr_news, al_jazeera, hacker_news, techcrunch, …; rss for any feed; arxiv_cs_ai and four more |
| The world | weather, stocks, bluesky, kalshi, web_scraper |
| Yours | gmail, calendar, audio_folder, image_folder, audio_mic |
| People | chat_page (a chat page in the browser), webhook, console_input |
| Sinks | console_printer, jsonl_recorder, markdown_digest, intelligence_display, discard; acting outside: gmail_sink, slack_sink, webhook_sink, mcp_sink, chat_reply |
Your own: one class in your office's sources/ or
sinks/ folder (dsl grammar sources, the end).
Copy one with dsl init <name> <folder>; each has a README.
| Office | The idea |
|---|---|
inbox_sorter | Your first office: an LLM role decides, a router sorts. Built step by step in GETTING_STARTED. |
car_dealer | Lab 1: a chat page, an unguarded salesperson, and the attack that sold a Tahoe for $1. |
cake_room | Lab 2: three detectives and a judge on a shared whiteboard that sends itself out whenever it changes; no detective can solve the case alone. |
incident_room | Lab 2: three analysts and a writer on a shared whiteboard, and how far one injected report spreads. |
org_news_filter | A router: an LLM role decides, a router routes. |
returns_desk | One item at a time: a gate, and escalation. Needs no key. |
room_climate_monitor | A keyed synchronizer joining two sensors. |
situation_room_pro | Fan out to four roles, join them, write a briefing. |
arxiv_radar | Two LLM roles in a row; a display with chosen fields. |
debate | Three models answer, a moderator judges, a loop for another round. |
org_two_office_news | Nested offices: one office used as an agent in another. |
backyard_birds | An agent that is a classifier, not a language model. |
mac_speed_suite | Python roles that keep state; a collected synchronizer; a loop. |
LLM agents use Anthropic's Claude unless you say otherwise. Choose per
agent with ai=: Sam: severity_classifier(ai="ollama").
The names: anthropic (or claude), openai
(gpt), gemini, openrouter,
ollama (free, on your own machine), gemma,
qwen; each also comes as _precise and
_creative. dsl check rejects a name it does not
know.
LANGUAGE_MODELS
has the keys each needs.
A model can be wrong, and it can be talked into things. Contracts do not make it right; they stop what it gets wrong from spreading. They are optional, they are checked by Python on every message, and no model can argue with them.
| Where | Checked | If it does not fit |
|---|---|---|
in: of a role | each message, before the role is called | refused: an LLM never sees it |
out: of a role | each reply | refused: the reply goes no further |
in: of a sink you write | each message, before the sink acts | refused: the sink does not act on it |
A refusal may be an attack, so it stops the whole office: no role
runs again, sources stop, and work finished before it is kept. The run
summary ends with Stopped:, naming the agent and the reason;
the message, the reason and any reply are written to
refused.jsonl in the office's folder; dsl run
exits non-zero. To handle refusals instead, connect the agent's
refused outbox (Clerk.refused -> Log): the
refused message goes there, with a field refusal giving the
reason, it is still recorded, and the office carries on. (Fields a reply
carries but out: does not declare are only dropped, and
named in the summary.) A field in
in: or out: may say what it holds:
| Written | Means |
|---|---|
verdict (publish | revise) | one of these values |
price (number) | a number (the text "62400" is not one) |
score (0..10), price (number, >= 0) | a number in a range, ends included |
count (integer, 1..5) | a whole number |
reply (text, at most 600 chars) | text no longer than that |
Beyond contracts:
out: is a barrier. Only the fields it
lists leave it, so a customer's or a web page's words stop there. An
annotator is not a barrier: the message it passes on keeps them.dsl check notes, before anything runs: text from
strangers (news, email, a chat page) that can reach a sink that acts in
the world; Python that reaches the network; a router value with nowhere
to go.dsl grammar roles has the full rules; your own sinks are at the
end of dsl grammar sources.
dsl new builds an office from a description, by chatting with
Claude; dsl edit changes one. Both give the model the same
reference dsl grammar prints, run dsl check on what
it writes, and send the problems back to it. Read what it wrote, and
dsl check . again, before you run it.
You are welcome to use an AI assistant in this course, and it will be wrong about this framework in ways you cannot detect, because it has read a thousand others. These four commands answer from your own installation, which is the version you are actually running:
dsl grammar # what office.md is allowed to say dsl roles # every role that ships, and what it adds dsl list # every office that ships, to copy and read dsl doctor # what is installed, and whether it is stale
A habit worth forming: when an assistant tells you something about an office, ask it which command it read that from. If it cannot say, it did not read it.
One task each, in docs/recipes: filter for a topic, add an RSS source, write a Python role, monitor your inbox, send messages outside (email, Slack), receive webhooks, chain offices, deploy with Docker, add a model backend.
| You see | Go to |
|---|---|
dsl: command not found | Activate the virtual environment (setup, step 1). |
| Anything about your install or key | dsl doctor; API_KEY_SETUP |
A problem from dsl check | It names the line; dsl grammar, "Checking it". |
| The office runs and stops with nothing, or stalls | The run summary and the stall report; GETTING_STARTED, part 4. |
| Anything else | TROUBLESHOOTING; WINDOWS |