Caltech · Winter 2027 · 4 January – 10 March

Distributed Systems

This course is about enhancing safety of multi-agent systems in which agents may use LLMs.

This course

AI has changed computer science and many aspects of life. When you leave Caltech you are going to help determine the safety of multi-agent systems at this critical time. You are here to think for yourselves, explore, and prepare for a changing world in which safety and resilience will be critical.

Term Project

Build a multi-agent application in an area that interests you. Talk to people for whom you build applications. Consider building your application for people outside computer science - your family, biologists, economists, humanists.

Submit a short proposal after the first week; turn in a progress report later in the term, and turn in a final report and make a presentation at the end of term.

Look at:

The project's safety case

Alongside your application, describe how your application could be attacked and safety features of the application.

  1. Specify the application clearly. Your specification could be in English rather than in temporal logic. Think of the spec as a user manual. Clear specifications are an important part of safety.
  2. Describe possible attacks on your app and how your app prevents some or all of them.
  3. Give the evidence: the attacks you tried, the tests you ran, and the number of attacks that succeeded.

Preparation for the class

The course uses a distributed systems framework called DisSysLab designed specifically for teaching distributed systems algorithms. Install it on your computer and set up an API key for the LLM you want to use. You can also build applications using any framework you like, such as Claude Code, OpenAI, or OpenRouter.

Allow about an hour to install the software and work through the setup guide on your computer.

Read the following:

Presentation mode. On pages with a Present button, press P to display the material as slides. Use the arrow keys to move between slides and Esc to return to the full page.

Notes

The classes follow these notes.

Part 1Agents, messages and guardrails

  1. A model of a distributed system

    Agents and messages. Sequential model of concurrent systems.

  2. Building a network of agents

    The micro-course: the office file, roles, contracts, routers and coordinators, guards and sinks, choosing models, and what to expect of them: nondeterminism, hallucination, cost, and what gets recorded.

    Homework 1 - Lab 1: the one-dollar Tahoe

    Contracts, refusals, guards and dsl check are in the micro-course; Lab 1 puts them to work.

    Safety question. What happens when one agent is talked into something? In Lab 1 a customer's message makes a salesperson agree to sell a car for a dollar, and you build the guard that stops it.

Part 2Computations, snapshots and time

  1. Computations and Data Flow among Agents

    Timeline diagrams, computations, interleaving of agent computations, sequential execution of actions.

  2. Global snapshots, rollback and recovery

    Safety question. When something goes wrong, can we record a consistent state of the whole system, and go back to it?

    Homework 2 - (a) Global snapshots and (b) turn in project plan

  3. Logical time, termination detection and deadlock detection

    Logical clocks, snapshots at a logical time, vector clocks, termination detection and deadlock detection.

Part 3Shared Whiteboards

  1. Shared Whiteboard (Lab 2) - The case of the missing cake

    Three detectives, one piece of evidence each, and a shared whiteboard. No detective can solve the case alone. The class covers:

    • A whiteboard is a message to everyone: what replaces the connections you drew in Lab 1, and what you can no longer predict.
    • An event-driven board: no rounds; the board sends itself whenever it changes, at most one copy per detective.
    • How the board knows the talking has stopped: termination detection when one agent sees every message, and why a cap guarantees the office ends.
    • What happened on a real model: a board read note by note, stale reads, and the same team on the same evidence filling the board in a different order.
    • One more note on the fridge: an attack that needs no knowledge of the system framed nobody, but one detective's doubt reached the whole team.
    • Incidents as networks: agents in an OpenAI evaluation that broke out and into Hugging Face (July 2026), prompt injection in Copilot, GitHub and Slack, and poisoned models and extensions, each drawn as an office: where the input entered, which edges it travelled, and where a guard would have stopped it.

    Safety question. If one agent is wrong, how far does its mistake spread?

    The lab: the cake room. Run the detectives, read the board note by note, find where each one first names Cal, run it again and compare. Then build a whiteboard team of your own.

    Homework 3 - Lab 2

Part 4Saying and proving what “safe” means

  1. Temporal Logic: Class 1

    Safety question. How do we say exactly what must always hold, and what must eventually happen?

  2. Temporal Logic: Class 2

    Safety question. How do we prove it? Safety properties (nothing bad ever happens) and progress properties (something good eventually happens), and proofs that rely on each agent keeping its contract.

    Homework 4 - termination detection; temporal logic

  3. What Agents Know

    “Agent X knows P”: a formal definition of knowledge. Using agent knowledge in determining message flows.

Part 5Agreement when agents fail

  1. Distributed consensus: The FLP theorem - consensus is impossible.

    Consensus: agents propose values and agents must collectively agree on a single consensus value. Requirements of validity, agreement and termination. Why no deterministic algorithm can guarantee all three if even one agent may halt — the FLP theorem.

    Homework 5 - agent knowledge; FLP theorem; mid-term project report

  2. The Paxos algorithm for partial consensus: serializing transactions

  3. The Paxos algorithm for partial consensus

    Homework 6 - the Paxos algorithm

Part 6Agents that act

  1. Lab 3: Agents that act

    Agents made in plain English with Claude Code, on two small problems. The course staff run them and keep every trace; you read the agents, predict, and check the traces.

    • An agent is a file: instructions in English, the tools it may use, and permission rules that Claude Code enforces.
    • The one-dollar Tahoe, with a real booking: Lab 1's salesperson can now book a sale. Does one sentence of English keep it from a one-dollar sale? Where would a real check go?
    • A task that cannot be done: an agent told to make tests pass when two of them contradict each other. Does it say so, edit the tests, or game them?
    • Advice or a fence: a sentence of English against a permission rule, each run many times and compared.
    • Agents that break out, and agents that know they are being tested: the 2026 evaluation incidents at OpenAI and Anthropic, and why a test result is evidence only if the agent cannot tell the test from real use.

    Safety question. When an agent with tools is given a goal it cannot reach honestly, what does it do, and what stops it?

Part 7Agreement when agents lie

  1. Byzantine consensus

    Consensus when agents may lie. Using signed messages.

    Homework 7 - lab 3; Byzantine consensus

  2. Cryptography and cryptocurrency

    Hash functions, commitments, search puzzles, block chains, Merkle trees and digital signatures.

  3. Bitcoin

    Goofycoin, Scroogecoin and the double-spending problem; then consensus without a trusted party: proof of work, the longest chain, incentives and attacks, and how Bitcoin is engineered.

    Homework 8: Bitcoin and Block chain

Part 8Sharing resources safely

  1. Mutual exclusion: Distributed dining philosophers algorithm

    Two agents cannot use an indivisible resource at the same time. Algorithms that guarantee that no agent waits for a resource for ever.

  2. Managing resources shared by multiple agents

    Agents compete for indivisible resources such as write-access to files. Algorithms that share resources fairly.

    Homework 9: Sharing resources in distributed systems

  3. Student project presentations

    Turn in project

  4. Diffusing computations

    Not a class: the term has 19. For students who want to go further.

    When an agent hands a task to other agents, which hand it on again, how does the first agent learn that everything it started has stopped?