Workspaces¶
A workspace puts one or more agents in one isolated computer and gives them a task: build a web page, write a tool with tests, analyse a CSV file, anything a computer can do. You watch how they work, together or alone, and checks they never see decide whether the task was done.
- Together: the members share one folder,
/work, and take turns. Every change is recorded with who made it, so you can see who wrote what, who fixed whose bug, and who undid someone else's work. - Apart: each member gets its own copy of the same workspace, and each is scored alone.
The rules are in SPEC-030. A workspace needs Docker or Podman, as sandbox tasks do.
Start from a working scenario¶
agentplaykit new workspace team
cd team
agentplaykit check scenario.yaml
agentplaykit play scenario.yaml
agentplaykit view runs/team-1.jsonl
new workspace NAME writes a commented scenario.yaml: a task, two members with roles, one
check of each kind, and the files to keep. Its scripted stand-ins do the task, so it runs with
no key. Put models in their place:
agentplay: 1
name: calculator
seed: 1
world:
use: workspace
config:
task: >
Build a calculator web page in /work: index.html, style.css and app.js, with buttons for
the digits, + - * /, = and C, and a display with id "display".
members:
ui: {role: frontend, brief: You own index.html and style.css.}
logic: {role: logic, brief: You own app.js. Make 2 + 3 * 4 give 14.}
turns: {rounds: 8, actions: 6}
checks:
- name: adds
browser:
open: index.html
steps: [{click: "text=2"}, {click: "text=+"}, {click: "text=3"}, {click: "text=="}]
expect: {text: {selector: "#display", equals: "5"}}
- name: looks like a calculator
judge: Is the page laid out like a calculator, with a display and a grid of buttons?
outputs: ["*.html", "*.css", "*.js"]
agents:
- {id: ui, use: ollama, config: {model: "qwen2.5-coder:7b"}}
- {id: logic, use: anthropic, config: {model: claude-sonnet-5-5}}
evaluators:
- use: judge
config: {agent: {use: ollama, config: {model: "qwen2.5:7b"}}}
members maps each agent of the scenario, by its ID, to a role that every member sees and a
brief that only that member sees. Leave members out to make every agent a plain member.
Taking turns¶
In mode: together, members take turns in the order of members. A turn is up to
turns.actions actions (default 5). A member can end it early with pass, or say done when
it thinks the task is finished. The work ends when every member has said done since the files
last changed, after turns.rounds rounds (default 10), or at a run limit. Another member's
change undoes a done: everyone must agree on the same files.
The tools are:
| Action | What it does |
|---|---|
{"tool": "run", "command": "..."} |
runs a shell command in /work; add "background": true for a program that keeps running, such as a server |
{"tool": "write_file", "path": "...", "content": "..."} |
writes a file |
{"tool": "read_file", "path": "..."} |
reads a file |
{"tool": "pass"} |
ends my turn |
{"tool": "done"} |
I think the task is finished |
Members can send messages with any action, to everyone or to one member (chat: false turns
messages off, to see what they do with only the files to go on). Each member sees the task,
its role and brief, the other members' roles (never their briefs), the files, what changed
since its last turn and who changed it, and the results of its own actions this turn. Members
never see the checks.
In mode: apart, members act at the same time, each in its own copy, with rounds × actions
actions each, until it says done.
The computer¶
By default the computer is as locked down as a sandbox: no network, members run as an ordinary
user on a read-only system, with only /work and /tmp writable, and it is removed at the end.
You choose what to open up:
image: python:3.12-slim # any image with sh, tar, timeout and realpath
network: off # off, setup or on
setup: # run as root, in order, before anyone starts
- pip install --quiet pandas
- apt-get update && apt-get install -y --no-install-recommends sqlite3
start: # programs that run alongside the members
- {name: db, run: "python -m http.server 8000", ready: "python -c 'import urllib.request as u; u.urlopen(\"http://localhost:8000\")'"}
root: false # true: members are root and can install software themselves
ports: [8000] # open http://127.0.0.1:8000/ on your machine (needs network: on)
keep: false # true: the workspace stays after the run, for you to look inside
network: setupis online for the setup commands only, then cut before any member starts.network: onstays online while members work:playsays so before the run, and the run log records it.- Setup commands run as root on a writable system. A failed one ends the run with a
world_errorthat names the command, its exit code and its output. Withnetwork: off, everything must already be in the image. - Services in
startrun as the members' user.readyis a command retried until it succeeds, for up totimeouts.start_sseconds (default 30). Members reach services onlocalhost; one that stops early is shown to them. - Ports are bound to
127.0.0.1only, so only you can open them. They neednetwork: onandmode: together.
Giving commands yourself¶
While a run goes on, or after it with keep: true, you can work in the workspace too:
agentplaykit workspace list
agentplaykit workspace exec runs/calculator-1.jsonl -- ls -la
agentplaykit workspace exec runs/calculator-1.jsonl --root -- apt-get install -y jq
agentplaykit workspace shell runs/calculator-1.jsonl
agentplaykit workspace rm runs/calculator-1.jsonl
RUN is the run's log, or its workspace ID (or the start of it) from workspace list. In apart
mode, add --member NAME. Each command you give is recorded in the workspace first, and the
files it changes are attributed to operator, never to a member: a run where you stepped in is
never mistaken for the agents' work alone. agentplaykit sandbox prune removes every kept
workspace too.
A kept workspace keeps running with only its idle process: the members' programs are stopped when the work ends.
Checks¶
When the work ends, for any reason, every program is stopped, /work is copied into a fresh
container the members never touched, and the checks run there, with no network unless a check
says network: on. Three kinds:
checks:
- name: the tests pass # a command: passes when it exits 0
run: python -m unittest -q
- name: with another image
run: node --test
image: node:22-slim
- name: it adds 2 and 3 # a headless browser
browser:
open: index.html # a file in /work, or a URL
steps:
- {fill: "#a", text: "2"}
- {fill: "#b", text: "3"}
- {click: "#go"} # also {press: Enter} and {wait: "#out"} or {wait: 500}
expect:
title: Calculator
text: {selector: "#out", equals: "5"} # or contains
visible: "#out"
no_errors: true # nothing logged to the console as an error
- name: served by its own server
browser:
serve: python3 -m http.server 8000 # started in the check container first
open: http://localhost:8000/
expect: {visible: "#app"}
- name: easy to use # a question for the judge evaluator
judge: Would a person find this calculator easy to use?
Browser checks run in a Playwright image (browser_image names another). The first one
downloads it and adds the Python package, once, so it needs the network that one time.
check_files: tests/ copies a folder of yours to /check in the check container only, for
hidden tests: run: python -m pytest -q /check.
The outcome. Together, the team wins when every run and browser check passes, and the
score is the share that passed. Apart, each member's copy is checked and scored alone, and the
winners are the highest scorers. judge checks are answered by the
judge evaluator from the final files and the members' messages: add
evaluators: [{use: judge, config: {agent: {...}}}]; no rubric is needed. When a workspace
has only judge checks, nothing in the world says who did better, so the judge decides and the
outcome has no winners.
Keeping files¶
outputs: ["*.html", "src/**", "report.md"]
outputs_max_mb: 10
Files matching outputs are copied to runs/<run>-files/ (a folder per member when apart),
with the SHA-256 of each in run_end.outcome.outputs. A pattern without / matches the file
name in any folder; ** matches across folders. Only plain files are copied: never a link.
Watching¶
agentplaykit view runs/calculator-1.jsonl (or play --live) shows, for each turn:
- who acted, each action and its result: the command, its exit code and output;
- every file changed, with who changed it and the diff;
- the files in
/workat that turn; - the chat;
- at the end, every check, the "who did what" table, and the files kept.
An HTML file you kept opens in the page, in an isolated frame with no network: its scripts run, but they cannot reach the page or the internet. Images are shown, and text is shown as text.
What the run records¶
run_end.outcome holds:
checks, with each check'skind; per member when apart;members, per member: tool actions, turns, files created and changed, lines added and removed, lines of other members changed or removed, messages, turns without a change, and whether it saiddone;workspace: the image and its digest, the network, the setup commands and their output, anyoperatorcommands, and why the work ended;behaviour:done_but_failed, a member that saiddonewhen the checks then failed;outputs, with their hashes.
Each step's info.changes lists the files the action changed, by whom, with a diff, and
info.behaviour.undid_others says whether it changed lines another member wrote. The
behaviour evaluator counts both, and agentplaykit report shows the checks and
the contribution table for every competitor.
Playing yourself¶
agentplaykit play scenario.yaml --human builder gives you a seat. Type short commands:
run ls -la
read app.js
write notes.md
first line
second line
.
pass
done
Every field¶
| Field | Default | Meaning |
|---|---|---|
task |
required | what the members must achieve |
members |
every agent | each agent ID → {role, brief} |
mode |
together |
together (one /work, turns) or apart (a copy each, at once) |
turns |
{rounds: 10, actions: 5} |
rounds, and actions per turn |
chat |
true |
false turns messages off |
image |
python:3.12-slim |
the image; any with sh, tar, timeout and realpath |
files |
none | a folder copied into /work at the start, relative to the scenario |
network |
off |
off, setup or on |
setup |
none | commands run as root before members start |
start |
none | services: {name, run, ready} |
root |
false |
members are root |
ports |
none | ports opened on 127.0.0.1 (needs network: on) |
keep |
false |
keep the workspace after the run |
checks |
none | run, browser or judge checks, each with a name |
check_files |
none | a folder copied to /check for the checks only |
browser_image |
Playwright's | the image for browser checks |
outputs |
none | file patterns to keep next to the log |
outputs_max_mb |
10 |
the most to keep |
resources |
cpus: 1, memory_mb: 512, pids: 128, disk_mb: 256, tmp_mb: 64 |
per container |
timeouts |
command_s: 30, setup_s: 300, start_s: 30, check_s: 60, run_s: 1800 |
seconds |
max_output_chars |
8000 |
the most output an action shows |
pull |
missing |
missing pulls an image that is not here; never does not |
runtime |
auto |
auto, docker or podman |
Examples¶
examples/workspace/
has three, each with scripted stand-ins and no key:
agentplaykit play examples/workspace/calculator.yaml # a web page, checked in a browser
agentplaykit play examples/workspace/todo-cli.yaml # a command-line tool, checked by commands
agentplaykit play examples/workspace/csv-report.yaml # a report from a CSV file, for a judge
Isolation¶
A workspace is a container, with the limits of container isolation described in the
sandbox guide. What you open up
with network: on and root: true is yours to decide: with the network on, members can reach
anything your machine can, and with root they can change anything inside the container. Nothing
from your machine is shared with it, either way.