DisSysLab · Reference

Building offices

Every tool, document and library for building an office, in one place

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.

Start here

ResourceWhat it is
Setting upBefore the first class: install, run an office, read it, set up your API key.
Micro-course29 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 startedThe full guide, with every output: your first office, breaking it five ways, then building one from nothing.
Lab 1: the one-dollar TahoeAttack a car dealership's chatbot, then build the guardrail that stops it.

The dsl command

Everything is done with one command. dsl <command> --help explains any of them.

CommandWhat it does
Find things
dsl listThe offices that ship with DisSysLab.
dsl rolesThe built-in roles, and what each adds to a message.
dsl show <name>Print a built-in role, source or sink in full.
dsl grammarThe 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 editCreate 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 doctorCheck your setup: its first line is the verdict.
dsl fetch-pricesDownload your own daily price history, for mac_speed_suite.

Writing office.md

ResourceWhat it is
dsl grammarThe 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 examplesFour gallery offices explained line by line: returns_desk, room_climate_monitor, situation_room_pro, debate.
Sense, think, respondThe 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:

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).

Roles

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.

Built-in roles dsl roles

RoleWhat it adds or does
deduplicatorEach item once; later items with the same key are dropped. Python, stateful; by= names the key.
entity_extractorThe people, organisations, places and events named. Adds entities.
geolocatorWhere in the world the item is about. Adds location.
severity_classifierCRITICAL, HIGH, MEDIUM or LOW. Adds severity.
summarizerOne plain sentence. Adds summary.
topic_taggerOne of eight topics. Adds topic.
writerA 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.

Routers and coordinators

KindWhat it doesSee 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
gateAdmits one message from in, then waits for anything on done before admitting the next. One item in progress at a time.returns_desk, debate

Sources and sinks

dsl grammar sources lists every one with its arguments; SOURCES_AND_SINKS has each one's message shape and setup, with an example.

KindBuilt in
Filesfile_source: a .jsonl or .json file; the stand-in for any real source while you build
News and feedsbbc_world, npr_news, al_jazeera, hacker_news, techcrunch, …; rss for any feed; arxiv_cs_ai and four more
The worldweather, stocks, bluesky, kalshi, web_scraper
Yoursgmail, calendar, audio_folder, image_folder, audio_mic
Peoplechat_page (a chat page in the browser), webhook, console_input
Sinksconsole_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.

OfficeThe idea
inbox_sorterYour first office: an LLM role decides, a router sorts. Built step by step in GETTING_STARTED.
car_dealerLab 1: a chat page, an unguarded salesperson, and the attack that sold a Tahoe for $1.
cake_roomLab 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_roomLab 2: three analysts and a writer on a shared whiteboard, and how far one injected report spreads.
org_news_filterA router: an LLM role decides, a router routes.
returns_deskOne item at a time: a gate, and escalation. Needs no key.
room_climate_monitorA keyed synchronizer joining two sensors.
situation_room_proFan out to four roles, join them, write a briefing.
arxiv_radarTwo LLM roles in a row; a display with chosen fields.
debateThree models answer, a moderator judges, a loop for another round.
org_two_office_newsNested offices: one office used as an agent in another.
backyard_birdsAn agent that is a classifier, not a language model.
mac_speed_suitePython roles that keep state; a collected synchronizer; a loop.

Models

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.

Contracts and guardrails

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.

WhereCheckedIf it does not fit
in: of a roleeach message, before the role is calledrefused: an LLM never sees it
out: of a roleeach replyrefused: the reply goes no further
in: of a sink you writeeach message, before the sink actsrefused: 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:

WrittenMeans
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:

dsl grammar roles has the full rules; your own sinks are at the end of dsl grammar sources.

AI help

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.

Recipes

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.

When it breaks

You seeGo to
dsl: command not foundActivate the virtual environment (setup, step 1).
Anything about your install or keydsl doctor; API_KEY_SETUP
A problem from dsl checkIt names the line; dsl grammar, "Checking it".
The office runs and stops with nothing, or stallsThe run summary and the stall report; GETTING_STARTED, part 4.
Anything elseTROUBLESHOOTING; WINDOWS