Pico
(2026)
- Developer tool · AI agents
- React
- Node.js
- Local-first
A browser workspace for coding agents. An agent keeps its work when the connection stops, the tab sleeps or the server restarts.
The problem
A coding agent can work for many minutes. During that time, the phone can lock, the Wi-Fi can stop and the tab can reload. The server can crash, or restart after each build.
After each of these events, the screen must show the true state of the session. And the agent must not do an action two times: send a notification, start a job or start a child session.
My role
I made Pico: the product idea, the interface design, the server, the web client and the local-first architecture.
Pico runs its agents on the open-source pi-durable runtime (@earendil-works/pi-durable). The runtime records each step of a run in SQLite. When it starts again, it continues the runs that are not complete. Pico adds three parts: the live event stream, the reconnection logic in the browser and its own agent tools. These tools obey the replay rules of the runtime.
See it work
The live event stream
The browser gets all live updates through one Server-Sent Events stream. Each event has an ID. On a new stream, the first message is always a full baseline of the session. After that, the server sends only patches to the state that the browser has.
A. Connecting
The browser opens the stream. It sends the ID of the last event that it got. It keeps this ID in memory and in session storage.
B. Replaying
The server sends the events that the browser did not get. It keeps a window of the last 512 events. It does not send old state events, because the baseline replaces them.
C. Baseline
The server sends the full state of the selected session and the list of sessions. Events that arrive during this step wait in a queue.
D. Live
The server sends each new state as a patch: the start position, the number of items to delete and the new items. Streamed text arrives in small parts (deltas).
E. Checking
The stream failed. The browser asks the health endpoint if the server is up.
F. Unreachable
The server does not answer. The page shows one “server unreachable” view, not one error for each request.
One tool call through a crash
Each tool call is a durable task. The runtime records the intent of the call before the tool runs. If the process stops during the call, the next process uses the replay policy of the tool to decide what to do. Pico marks its tools with external effects as replay-safe. Before each of these tools acts, it reads a stored memo.
A. Intent stored
The runtime records the call before the tool runs.
B. Running
The tool does its work.
C. Result stored
The result goes into the transcript.
D. Cut off
The process crashed or restarted during the call.
E. Interrupted
The tool is not replay-safe. The model gets an “interrupted” error with the output until that point, and decides what to do.
F. Rerun
The tool is replay-safe. It runs again from the start, and first reads its memo.
The live stream stops
A phone locks, the network changes or a proxy returns a 502 error. The browser does not get the events that the server sends during the gap.
Each event has an ID. The browser keeps the last ID in session storage. A new stream sends this ID back, and the server sends the missed events again from its window of 512.
Event IDs start from the clock time when the server starts, so they increase across restarts. An ID from before a restart gets no replay. The baseline replaces it.
If the window does not have the ID, the server sends a resync notice and the full baseline. The browser never applies a patch to the wrong state.
After the baseline, each change is a small splice. The server finds the items that are the same at the start and at the end of the list. It sends only the items between them.
The window keeps only the newest state event of each session. Old full states do not push the small events out of the window.
The server is down
All requests fail at the same time. Without a guard, the page shows one error message for each failed request.
One small store holds the connection state: unknown, online or unreachable. When a request or the stream fails, the store asks the health endpoint one time.
While the server is down, the store asks again after 1 s, 2 s and 3 s, and then every 5 s. The page shows one “server unreachable” view.
When the server answers, the page opens a new stream with the saved event ID and loads its data again.
A tab that returns after 30 s or more in the background reconnects immediately if its stream is closed.
A crash or restart stops a run
The process stops in the middle of a run. The agent must not lose the work, and it must not start again from zero.
The sessions are in one SQLite database. The pi-durable runtime records a checkpoint at each step of a run. When Pico starts again, the runtime continues the runs that are not complete.
Pico keeps the state of its tools in documents, not in server memory. A restart does not delete a todo list, a timer, a question or a link to a child session.
If a timer was due while the server was down, it fires one time at startup. Its follow-up message has a fixed request ID for each run, so the runtime refuses a second delivery.
Terminals and background jobs run in a separate process, pico-pty-host. After a server restart, the server controls the jobs that continue to run, and records the jobs that stopped. A job without a process gets the status “lost”, and Pico reports it. Pico does not show it as complete.
A tool with side effects runs two times
A replay-safe tool runs again after a crash. Without a guard, it sends a second notification, starts a second job or makes a second child session.
Each tool with an external effect reads its memo first. If the memo has a result, the tool returns that result and does nothing more.
When job_start runs again, it reports the job that it started before. It never starts the command a second time.
When spawn_session runs again, it finds the child that the same tool call made. The first message to the child has the request ID spawn:<call ID>. If the runtime already has a request ID, it returns the existing submission.
One gap is still open: the effect and its memo are two steps. A crash between these steps can repeat the effect. If the effect is a message to a session, the fixed request ID closes the gap.
Numbers
512 — events in the replay window
MAX_REPLAY_EVENTS in apps/pico/server/src/events.ts.
1, 2, 3, 5 s — between health checks while the server is down
RETRY_DELAYS_MS in apps/pico/src/lib/pico/server-connection.ts.
30 s — in the background before a tab reconnects
RESUME_RECONNECT_AFTER_MS in apps/pico/src/features/pico/use-app-shell-session-sync.ts.
121 — server test cases in 26 files
Counted test( declarations in apps/pico/server/test with grep, at commit abae556, on 27 October 2026. Counted, not run.
On a phone
More work
Paths are in the public alivault/pico repository at commit abae556.