Build an OpenSwarm-style multi-agent app
~25 min TypeScript PythonWhat you’re building: An AI desktop built around running several agents in parallel.
Primitives you’ll use: Sandbox, Computer, Agent and harness, Deployment (App Engine)
Agent prompt
Start with your coding agent
Choose what you are building. The brief names the product it is modelled on, maps it onto MIOSA, and lists the exact commands. Copy it into OSA, Claude Code, Codex, or Cursor.
Template coming soon1 What are you building?
Leave it empty and your agent will propose 3 names, pick one, and use it for resources, the domain and branding.
3 Configure
Reference product
OpenSwarm, by OpenSwarm (https://openswarm.com): an AI desktop app built around running several agents in parallel (proprietary; distributed as signed builds).
How it works: An orchestrator breaks a goal into parts and runs agents on them at the same time, then combines what they return.
Key capabilities:
An orchestrator that runs agents in parallel
Each agent works on a part of the goal
A combined result
A desktop to watch and steer it
Build an app LIKE OpenSwarm. It is not affiliated with OpenSwarm: do not copy its name, branding or assets. Open https://openswarm.com first, confirm the capabilities above, and note anything this brief missed.
How it maps onto MIOSA
An orchestrator that plans and delegates -> agent runs (`miosa prompt`, client.runs) streaming events from your orchestrator process in its own sandbox
Workers that run in parallel -> one sandbox per worker (`orchestration_role`, `agent_run_group_id` tie them together)
Shared starting state -> sandbox snapshots and fork: snapshot once, restore into each worker
Joined result -> client.runs.waitForCompletion, then run outputs and files from every worker
Goal
Build an app like OpenSwarm on MIOSA, as a multi-tenant product sold to my customers. Each customer is isolated in its own workspace; I meter usage and bill them.
Product name: propose 3 product names, pick one, and use it for resource names, the domain and branding. Until you pick, <product-name> stands for it in the commands below.
Scale: a prototype.
Set up
npm i -g @miosa/cli
miosa login && miosa whoami
miosa api-key create <product-name>-key --preset agent
export MIOSA_API_KEY="msk_u_..."
miosa org
miosa connections add models # your own model provider key
Resources
Sandbox: the agent's isolated Linux workspace
miosa create <product-name>-box --wait
Computer: a persistent Linux desktop with a browser
miosa computer create <product-name>-desktop
Agents and harnesses: what a run can use
miosa agent harnesses
Deployment: a stable, versioned URL
miosa deploy create --from-sandbox <product-name>-box --name <product-name> --wait
Data and storage
Keep the plan (subtasks, owners, status) and each worker's result keyed by the run group id, so a failed join can resume and the UI can show who did what.
Auth and tenancy
Your organization is the platform; customers never get a MIOSA account, they sign into YOUR product. One workspace per customer, created as they onboard, isolates their machines, runs and data.
miosa workspace create <product-name>-customer-1
Tag every machine and run with the customer id in `metadata`, and never query across customers. Meter usage per customer with GET /api/v1/usage and set who pays with PUT /api/v1/bill-to (/docs/platform/usage-and-billing).
Agent loop
Harness: OSA is MIOSA's own harness and works with any model provider you connect, including your own model.
Model: Anthropic (Claude). Calls use my own provider key (`miosa connections add models`); MIOSA platform keys are never used.
Sessions: one chat per project or conversation, so the agent keeps its context. The first `miosa prompt` on a sandbox uses `--new-chat` (a chat id is printed); every later turn passes `--chat <chat-id>`. `--reuse chat` keeps one new machine per chat so files persist.
Streaming: follow a run with `miosa run follow <run-id>` or client.runs.streamEvents(run.id), and steer or stop it with `miosa run steer` and `miosa run interrupt`.
The orchestrator is an agent that decides the subtasks; workers are separate harness runs, each on its own machine. Give each worker a narrow role and only the tools it needs. Cap the number of workers and the depth of delegation.
Steps
1. Create the orchestrator's own sandbox. It plans and delegates; it does not do the work.
miosa create <product-name>-orchestrator --wait
Check: The orchestrator can create other sandboxes with the SDK.
2. Create one worker sandbox per child agent (a fresh, isolated machine each).
miosa create <product-name>-worker-1 --wait
miosa create <product-name>-worker-2 --wait
Check: Two workers are running and cannot see each other's files.
3. Create ONE shared computer for children that need a desktop or browser.
miosa computer create <product-name>-desktop
Check: A desktop child can open a browser; code children never touch it.
4. Snapshot the orchestrator workspace once and restore it into each worker so they start from the same state.
sandbox.snapshots.create("shared start")
Check: Every worker begins with identical files.
5. Fan out: dispatch one run per worker, tied together by a group id and a role.
miosa prompt --sandbox <product-name>-worker-1 --harness osa --model <anthropic-model-id> --chat <chat-id> "<subtask>"
client.agentRuns.run({ provider: "osa", targetKind: "sandbox", targetId: worker1.id, orchestration_role: "researcher", agent_run_group_id: "grp_1", prompt: "<subtask>" })
Check: The runs execute in parallel and show the same group id.
6. Join: wait for every run, collect each output and files, and let the orchestrator merge them. Retry only the worker that failed.
client.runs.waitForCompletion(run.id)
miosa run outputs <run-id>
miosa run files <run-id>
Check: One failed worker is retried without rerunning the others.
7. Publish the joined report or the orchestrator UI.
miosa deploy create --from-sandbox <product-name>-orchestrator --name <product-name> --dir /workspace --wait
Check: The public_url shows the joined result.
Limits and costs
Parallelism multiplies cost: cap workers per job and give every run `--max-time`.
Use `idempotency_key` on `sandboxes.create` in retry loops so a retried fan-out does not create duplicates.
Prefer fewer, better-scoped workers over many shallow ones.
Prototype: keep it to one machine at the default size, skip replicas and custom hostnames you do not need, and delete everything when you are done.
Acceptance checks
Every child run completes and its output is collected.
Children are isolated from each other; only desktop children share the computer.
The orchestrator's final answer cites which worker produced what.
Each customer is isolated in its own workspace and usage is metered against them.
Everything it created can be deleted with nothing left running.
What your choices added
- Build a product. a workspace per customer, per-customer metering and bill-to
- Agent suggests a name. proposes 3 product names and picks one; commands use <product-name>
- Harness: OSA. dispatches with `miosa prompt --harness osa`
- Model: Anthropic. your own provider key
- Prototype. one small machine, no extras, easy to delete
- Multiple agents. already part of this guide
What you're building
an AI desktop app built around running several agents in parallel (proprietary; distributed as signed builds) Modelled on OpenSwarm, by OpenSwarm.
An orchestrator breaks a goal into parts and runs agents on them at the same time, then combines what they return.
Primitives you'll use: Sandbox · Computer · Agent and harness · Deployment (App Engine)
- An orchestrator that runs agents in parallel
- Each agent works on a part of the goal
- A combined result
- A desktop to watch and steer it
Source: openswarm.com. OpenSwarm is a trademark of its owner; this guide is not affiliated with or endorsed by them.
What you need on MIOSA
Each row is one thing to create before you start. The number matches the step that uses it.
- Organization and API key Scopes every call; a workspace key is all a worker needs.
miosa api-key create app-key --preset agentDocs - Sandbox The isolated Linux workspace the agent writes code and runs commands in.
miosa create app-box --template nextjs --waitDocs - Computer A persistent Linux desktop for browser, mouse, and screenshot work.
miosa computer create app-desktopDocs - A workspace per customer Isolates each customer’s machines, deployments, and data as they onboard.
miosa workspace create customer-1Docs - Branding and white-label Your name and slug on previews, deployments, and the desktop; customers never see MIOSA.
miosa orgDocs - Usage metering and bill-to Usage per customer, and which account pays for new machines.
miosa org billDocs - Agent and harness Turns a prompt into work: pick the harness and model a run uses.
miosa agent harnessesDocs - Deployment (App Engine) Publishes the app to an immutable, versioned URL with rollback.
miosa deploy create --from-sandbox app-box --name app --waitDocs
Architecture
How it maps onto MIOSA
An orchestrator that plans and delegates -> agent runs (`miosa prompt`, client.runs) streaming events from your orchestrator process in its own sandbox
Workers that run in parallel -> one sandbox per worker (`orchestration_role`, `agent_run_group_id` tie them together)
Shared starting state -> sandbox snapshots and fork: snapshot once, restore into each worker
Joined result -> client.runs.waitForCompletion, then run outputs and files from every worker
Data and storage
Keep the plan (subtasks, owners, status) and each worker's result keyed by the run group id, so a failed join can resume and the UI can show who did what.
Auth and tenancy
Your organization is the platform; customers never get a MIOSA account, they sign into YOUR product. One workspace per customer, created as they onboard, isolates their machines, runs and data.
miosa workspace create openswarm-customer-1Tag every machine and run with the customer id in `metadata`, and never query across customers. Meter usage per customer with GET /api/v1/usage and set who pays with PUT /api/v1/bill-to (/docs/platform/usage-and-billing).
Agent loop
Harness: OSA is MIOSA's own harness and works with any model provider you connect, including your own model.
Model: Anthropic (Claude). Calls use my own provider key (`miosa connections add models`); MIOSA platform keys are never used.
Sessions: one chat per project or conversation, so the agent keeps its context. The first `miosa prompt` on a sandbox uses `--new-chat` (a chat id is printed); every later turn passes `--chat <chat-id>`. `--reuse chat` keeps one new machine per chat so files persist.
Streaming: follow a run with `miosa run follow <run-id>` or client.runs.streamEvents(run.id), and steer or stop it with `miosa run steer` and `miosa run interrupt`.
The orchestrator is an agent that decides the subtasks; workers are separate harness runs, each on its own machine. Give each worker a narrow role and only the tools it needs. Cap the number of workers and the depth of delegation.
Steps
Create the orchestrator's own sandbox. It plans and delegates; it does not do the work.
miosa create openswarm-orchestrator --waitCheck: The orchestrator can create other sandboxes with the SDK.
Create one worker sandbox per child agent (a fresh, isolated machine each).
miosa create openswarm-worker-1 --waitmiosa create openswarm-worker-2 --waitCheck: Two workers are running and cannot see each other's files.
Create ONE shared computer for children that need a desktop or browser.
miosa computer create openswarm-desktopCheck: A desktop child can open a browser; code children never touch it.
Snapshot the orchestrator workspace once and restore it into each worker so they start from the same state.
sandbox.snapshots.create("shared start")Check: Every worker begins with identical files.
Fan out: dispatch one run per worker, tied together by a group id and a role.
miosa prompt --sandbox openswarm-worker-1 --harness osa --model <anthropic-model-id> --chat <chat-id> "<subtask>"client.agentRuns.run({ provider: "osa", targetKind: "sandbox", targetId: worker1.id, orchestration_role: "researcher", agent_run_group_id: "grp_1", prompt: "<subtask>" })Check: The runs execute in parallel and show the same group id.
Join: wait for every run, collect each output and files, and let the orchestrator merge them. Retry only the worker that failed.
client.runs.waitForCompletion(run.id)miosa run outputs <run-id>miosa run files <run-id>Check: One failed worker is retried without rerunning the others.
Publish the joined report or the orchestrator UI.
miosa deploy create --from-sandbox openswarm-orchestrator --name openswarm --dir /workspace --waitCheck: The public_url shows the joined result.
Limits and costs
Parallelism multiplies cost: cap workers per job and give every run `--max-time`.
Use `idempotency_key` on `sandboxes.create` in retry loops so a retried fan-out does not create duplicates.
Prefer fewer, better-scoped workers over many shallow ones.
Prototype: keep it to one machine at the default size, skip replicas and custom hostnames you do not need, and delete everything when you are done.
Acceptance checks
Every child run completes and its output is collected.
Children are isolated from each other; only desktop children share the computer.
The orchestrator's final answer cites which worker produced what.
Each customer is isolated in its own workspace and usage is metered against them.
Everything it created can be deleted with nothing left running.