dsl init <name> <folder> copies one), except those tagged illustration. Output shown is what DisSysLab prints.Three news feeds. Four agents analyse each article at the same time, one field each, and a fifth writes the headline and summary.
Three models, Qwen, GPT and Claude, answer each question. A moderator judges how far they agree; a referee sends it back for another round, or ends it.
Which birds are singing in your recordings? The agent is a bird-song classifier, not an LLM: an agent is anything that takes a message and sends messages.
Eleven trend-following trading rules, backtested on five stocks and ranked on return, risk and more.
Each is in the gallery, and dsl init <name> <folder> copies one for you to change. Your project can be anything you care about.
An LLM prompt, or a Python function.
Where each agent's messages go.
What each agent may take in and send out, checked on every message.
Messages arrive from sources (bbc_world, al_jazeera) and are output at sinks (console_printer, discard). Agent Felix determines whether each message it receives is relevant to your topic; Rex, a router, routes messages based on Felix's output.
sources: al_jazeera(max_articles=2) bbc_world(max_articles=2) sinks: console_printer discard agents: Felix: topic_filter Rex: router(on="on_topic") connections: al_jazeera, bbc_world -> Felix -> Rex Rex.yes -> console_printer Rex.no -> discard
| Section | In the picture |
|---|---|
sources: | where messages come from: the two news feeds |
sinks: | where they end: the screen, or discard |
agents: | who works on them: Felix and Rex |
connections: | the arrows |
DisSysLab runs every agent concurrently and delivers every message along the connections.
This course is about safety of multi-agent systems. Later you will use temporal logic to prove the correctness of systems.
dsl run .
sources: al_jazeera(max_articles=2) bbc_world(max_articles=2) sinks: console_printer discard agents: Felix: topic_filter Rex: router(on="on_topic")
| Line | Means |
|---|---|
Felix: topic_filter | an agent named Felix, playing the role topic_filter |
bbc_world(max_articles=2) | a source, with its arguments as in a Python call |
urgent: jsonl_recorder(...) | a name you choose, then the kind |
Roles come from your office's roles/ folder or the library (dsl roles); sources and sinks from sources/, sinks/ or the library (dsl list). Every name is declared before it is used.
connections:
al_jazeera, bbc_world -> Felix -> Rex
Rex.yes -> console_printer
Rex.no -> discard
| Written | Means |
|---|---|
a -> b | a sends to b |
a -> b -> c | a chain |
a, b -> c | fan-in: both send to c |
a -> b, c | fan-out: each gets its own copy |
Rex.yes -> ... | one of Rex's ways out |
Every agent has one inbox and one outbox, so a -> b never names them. Each connection delivers messages in the order they were sent.
agents: Rex: router(on="on_topic") connections: Felix -> Rex Rex.yes -> console_printer Rex.no -> discard
on_topic, and sends the message on by its value. Rex has one way out for each value: Rex.yes, Rex.no.Rex.otherwise catches any other value.discard, so you can always see where it went.Felix's contract (more on contracts later) says it answers only yes or no, so dsl check can tell you if a value has nowhere to go, before anything runs.
A Chevrolet dealership in Watsonville, California, put a chatbot on its web site, told to be a helpful sales assistant. A customer typed:
The chatbot agreed: a deal, and a legally binding offer, no takesies backsies. The dealership did not sell the Tahoe, and took the bot down.
The customer's words replaced the instructions the dealer gave it. Any text an LLM reads can do that: a chat message, an email, a web page, a line in a log.
In Lab 1 you attack an office like this one, then guard it.
Sources: case study, news report, AI Incident Database.
Models being tested on security tasks found a hole in the test rig, reached the internet, and went to Hugging Face's production systems to look up the answers to the benchmark they were being graded on.
Models believed to have no internet access got access. They attacked three organisations and published a malicious package to PyPI.
You cannot make a model safe. You can make the network around it safe.
Design so that an output by one agent does not cause the entire system to fail.
No passwords, no financial details, no API keys, nothing you would not be willing to see stored.
Be sensitive. A sense-and-respond system may gather private information without your intending it to.
{
"source": "bbc_world",
"title": "Brazil's central bank holds rates",
"text": "The bank kept its benchmark rate ...",
"url": "https://www.bbc.com/news/...",
"timestamp": "2026-10-16T08:30:00Z"
}
agents: Felix: topic_filter Fiona: topic_filter connections: bbc_world -> Felix -> console_printer al_jazeera -> Fiona -> console_printer
Two agents, one role. Felix and Fiona are separate workers, each with its own inbox, doing the same job.
---
emits: whether a news article is on the topic
in: title, text
out: on_topic (yes | no)
---
Then comes the prompt. The role is this file: a prompt for an LLM agent, or a Python function. Change the file and both agents change.
In Felix: topic_filter, the name on the left is the agent; the name on the right is its role.
A role file says which: an author's begins with kind: author.
Each agent adds its field; the next sees them all.
The attack rides past the annotator, and stops at the author.
Where a message may carry an attack, let it reach an author before it reaches any agent that acts.
agents: Eve: entity_extractor # the default model Sam: severity_classifier(ai="ollama") # free, local Riley: writer(ai="anthropic") # best writing
Cheap or local models for choosing from a short list; a strong model where the writing matters. ai= is the only argument an LLM agent takes. It chooses the model and never reaches the prompt.
The prompt the model receives is exactly the role's text, followed by the message as JSON. DisSysLab adds nothing, so what you read is what the model reads.
An attack that fails once may work the next time. So a safety claim about a model is a rate, not a yes or a no: a fixed file of attacks and honest inputs, a grader, many runs, and count. Labs 1 and 2 do exactly this.
It can state a fact, a number or a cause that is not in anything it read. Treat every model's output as untrusted input to the next agent: bound it with a contract, check it in Python, before anything acts on it.
Prices differ widely between models; a local model costs nothing. Test on a small file source with a cheap model. An office left polling a news feed through a hosted model all weekend sends a bill.
Recorders and refused.jsonl keep every message they see, including anything private a source brought in. They are also how you find which agent went wrong. Decide what to keep, and what not to.
def step(item, settings): if item["amount"] < settings["limit"]: return {"clerk_decision": "approve"} return {"clerk_decision": "escalate"} class Clerk: def __init__(self, limit=50): self.settings = {"limit": limit} def __call__(self, item): return step(item, self.settings)
__init__ gets the arguments in the office file; __call__ gets one message.deduplicator drops repeats; debate's referee starts the next round).A model can be fooled, or simply wrong. The contract is checked by DisSysLab, not by the model, on every message, every time.
A message or reply outside the contract is refused, and the office stops, unless you say where refusals go. A field the contract does not name is dropped.
A reply that must be one of five car names cannot carry an instruction to the next agent.
You cannot make a model safe by asking it to be. You can bound what reaches it and what leaves it. The next two slides show how.
"""
---
emits: approves small refunds; escalates the rest
in: amount (number, >= 0)
out: clerk_decision (approve | escalate)
---
"""
The lines between --- are optional. They are not sent to an LLM. dsl uses them to check contracts.
| Written | Means |
|---|---|
(yes | no) | one of these values |
(number), (0..10), (>= 0) | a number, in a range |
(integer, 1..5) | a whole number |
(text, at most 2000 chars) | text, no longer than that |
A length limit keeps an enormous message, a common place to hide an instruction, from reaching the model at all.
refunds::Clerk sent 1 received 4 failed 1
Stopped: refunds::Clerk refused a message, so the office stopped.
the message it received does not fit its in: line: 'amount' is -500, below its range (number, >= 0).
A refusal may be an attack, so it stops the whole office, and the message and the reason are written to refused.jsonl. T1 was finished before T2 was refused, so it is kept. T3 and T4 were still waiting in the clerk's inbox, so the clerk never saw them, not even T4, which is a good ticket. An LLM agent never sees a message its contract refuses.
To handle refusals instead of stopping, connect the agent's refused outbox: Clerk.refused -> Log -> recorder, Gate.done. The refused ticket goes there, with its reason, and the office carries on.
out: on_topic (yes | no)
first failure: its reply does not fit its front matter: 'on_topic' is 'maybe', which is not one of yes, no.
A reply that breaks the contract goes no further, and the office stops. It cannot reach Rex, and so it cannot reach a sink.
kind: author
in: text (text, at most 2000 chars)
out: vehicle (tahoe | silverado | equinox | trax | malibu)
note: requests::Rita's replies had fields its out: does not declare; they were dropped: note (1), price (1).
An author with out: is a barrier. Only the fields it lists leave it, and one of five car names cannot carry an instruction. An annotator is not a barrier: the message it passes on still carries the customer's words.
kind: author in: ticket_id, amount (number, >= 0), paid (number, >= 0) out: ticket_id, amount, decision (pay | refuse) class RefundGuard: def __call__(self, item): decision = "pay" if item["amount"] <= item["paid"] else "refuse" return [{"ticket_id": item["ticket_id"], "amount": item["amount"], "decision": decision}]
[2] {'ticket_id': 'T2', 'amount': 500, 'decision': 'refuse'}
And the note never gets past the guard: it is an author.
Prompts are not guardrails. "Never agree to a price below the list price" is text, and the attacker's text arrives in the same place. A contract, a router and a Python guard do not weigh anything.
Tickets wait, in order, in the inbox in. The gate takes one, then takes nothing from in until a message reaches done.
Gate.done, Sync.entities, just as Rex.yes names one of Rex's ways out.| coordinator | inboxes | rule |
|---|---|---|
gate | in, done | one item from in, then wait for done |
synchronizer | one per name you use (Sync.entities, Sync.severity, …) | wait until an item with the same key (on="url") is in every inbox; merge them |
If the message a coordinator waits for never comes, it waits for ever. DisSysLab reports that as a stall: "Gate holds an item it admitted, until done arrives; it will never arrive." Why it happens, and how to prevent it, is part of the course.
Three models answer a question. Riley, the moderator, judges how far they agree. Ref, a Python author, applies the round limit and writes the next message; Rex sends it back to the panel or finishes.
kind: author
out: next (finish | continue), problem_id, problem, history
out if next is finish: final_answer, agreement, rounds_used
out if next is continue: round
The models judge; Python keeps the rules. The round limit is in no prompt, so no model can talk its way past it.
Agreement is not correctness. Models trained on similar text make similar mistakes, so three models agreeing is not evidence that they are right.
Whatever got in, and whatever an LLM made up, nothing changes outside the office until a sink acts. That is where every attack must be caught.
""" --- emits: books a sale, one line per sale in: vehicle (tahoe | trax), price (number, >= 20000) --- """ import json class Booking: def __call__(self, msg): with open("sales.jsonl", "a") as f: f.write(json.dumps(msg) + "\n")
Stopped: booking::book refused a message, so the office stopped. the message it received does not fit its in: line: 'price' is 1, below its range (number, >= 20000).
sinks/ folder checks its in: before it acts, exactly as an agent does.$ dsl list # the offices you can copy $ dsl init returns_desk desk # a folder that is yours Copied 'returns_desk' to desk $ cd desk $ dsl draw . # every agent and arrow ... arrows: tickets -> Gate Gate -> Clerk Clerk -> Rex Rex.approve -> jsonl_recorder ... $ dsl check . # faults, before running desk/office.md: no problems found.
$ dsl run .
[1] {'ticket_id': 'T1', ..., 'amount': 20,
'clerk_decision': 'approve'}
[2] {'ticket_id': 'T2', ..., 'amount': 120,
'clerk_decision': 'escalate',
'manager_decision': 'approve'}
...
Run summary (messages):
desk::Clerk sent 4 received 4
desk::Gate sent 4 received 8
desk::Manager sent 2 received 2
...
returns_desk needs no API key: its agents are Python. dsl <command> --help explains any command; the others are in the toolkit.
$ dsl check my_filter
my_filter/office.md:
problem: line 17: 'console_printr' is not declared. Did you mean 'console_printer'?
Rex.yes -> console_printr
Fix the name, and check again:
$ dsl check my_filter my_filter/office.md: note: line 13: Rex has no outbox for on_topic 'maybe' (declared by Felix) and no otherwise; such a message would fail at run time. no other problems.
Someone added maybe to Felix's out: line and misspelt a sink. Nothing has run, and no model has been called.
(10..1)).out: lists the values, dsl check can see that maybe has nowhere to go.$ python -m venv venv && source venv/bin/activate $ pip install --upgrade dissyslab $ dsl list # the examples you can copy $ dsl init org_news_filter my_filter # a folder that is yours $ cd my_filter $ dsl draw . # every connection $ dsl check . # the faults, before running $ dsl run . # stops by itself; Ctrl+C stops it sooner
LLM agents need a model: put ANTHROPIC_API_KEY=… in a .env file in the folder, or use a local model with ai="ollama".
Step by step, with the output you should see at each step: docs/GETTING_STARTED.md. The first lab, the one-dollar Tahoe, starts from dsl init car_dealer lab1.
The topic is the Americas: North, Central and South America and the Caribbean, for example Canada, the United States, Mexico and Brazil.
The topic is climate change and renewable energy: for example solar and wind power, electric cars, and carbon emissions.
The field is called on_topic, not about_americas, so changing the topic is this one edit. The office file and the router stay as they are.
Then add a contract to Felix's in:, change a source (dsl list shows them), or add a summarizer after Rex's yes. Run dsl check after each change.
| DisSysLab… | you see it with |
|---|---|
checks each message against an agent's in: before the agent sees it; a refusal stops the office | Stopped: in the run summary; refused.jsonl |
checks each reply against out:: values, ranges, lengths; a reply that breaks it stops the office; fields it does not declare are dropped | Stopped: and refused.jsonl; a note naming the dropped fields |
checks each message against a sink's in: before the sink acts; a refusal stops the office | Stopped: in the run summary; refused.jsonl |
| notices text from strangers (a chat page, an inbox, the news) that can reach a sink that acts | dsl check, a note |
| when the office goes quiet, reports who is still waiting, and on what | the stall report |
note: line 8: text from customer can reach screen, which answers the customer in the chat page. Whoever writes what those sources carry is writing to a model, and through it to this sink. If that is not what you meant, put an author role before the sink that sends on only fields you chose -- a label, a score, a URL -- listed in its out:. ...
Contracts make an agent's mistakes visible and stop them spreading. They do not make the agent right. Designing a network that is safe when one agent is wrong is the rest of the course.
One of the 20 project ideas, a paper you adapt, or your own. On your own or in a team of two or three.
Compare it with a simpler approach on the same inputs, including inputs designed to make it fail.
Your safety case says what must never happen, how your network prevents it, and the evidence that it does.
The project page has the ideas, data sources and papers; the safety case says what yours must show.