Smith
(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 agent. And the agent must not do an action two times: start a job, start a subagent or set a timer.
My role
I made Smith: the product idea, the interface design, the server, the web client and the local-first architecture.
Smith 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. Smith 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 server first sends the events that the browser did not get, then a full baseline of the agent. After that, it 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 agent and the list of agents. 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. Smith marks most of its tools with external effects as replay-safe. Before such a tool acts, it looks for a record of the same call: a stored memo, or an entry in a document.
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 looks for its record.
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 agent. 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 agents are in one SQLite database. The pi-durable runtime records a checkpoint at each step of a run. When Smith starts again, the runtime continues the runs that are not complete.
Smith 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 subagent.
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, smith-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 Smith reports it. Smith 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 makes a second subagent, sends a message two times or sets a second timer.
Each replay-safe tool with an external effect first looks for a record of the same call. If it finds a result, the tool returns that result and does nothing more.
When spawn_subagent runs again, it finds the subagent that the same tool call made. The first message to the subagent has the request ID spawn:<call ID>. If the runtime already has a request ID, it returns the existing submission.
The schedule and watch tools make their task and record the call ID in one transaction. A rerun finds the record and does not set a second timer.
job_start is not replay-safe, so the runtime does not run it again. The model gets an “interrupted” error, and the job continues in smith-pty-host. The tool also keeps the job ID in a memo: if it runs again, it reports the job that it started before and does not start the command a second time.
One gap is still open: for a tool with a memo, the effect and its memo are two steps. A crash between these steps can repeat the effect. If the effect is a message to an agent, the fixed request ID closes the gap.
Numbers
512 — events in the replay window
MAX_REPLAY_EVENTS in apps/smith/server/src/events.ts.
1, 2, 3, 5 s — between health checks while the server is down
RETRY_DELAYS_MS in apps/smith/src/lib/smith/server-connection.ts.
30 s — in the background before a tab reconnects
RESUME_RECONNECT_AFTER_MS in apps/smith/src/features/smith/use-app-shell-agent-sync.ts.
240 — server test cases in 48 files
Counted test( declarations in apps/smith/server/test with grep, at commit f1839f1, on 21 November 2026. Counted, not run.
On a phone
More work
Paths are in the public alivault/smith repository at commit f1839f1. Smith was called Pico until November 2026.