Runtime and session state
When you ask Harness to read notes.txt, the terminal shows the work while a daemon runs it. The CLI checks for a daemon serving the selected kernel directory, normally ~/.harness. If none answers, it starts a detached Node.js process. The terminal UI connects through <kernel>/daemon.sock.
Terminal client │ local socket ▼Daemon process ├─ settings and connections ├─ session documents ├─ model requests │ └─→ model services └─ tool execution ├─→ files and processes └─→ external servicesThe daemon hosts kernel, project, and session services in one server process. The terminal UI is separate. Other clients can attach to the same session and observe the same work without starting another agent loop for it.
The session holds work, not just messages
Section titled “The session holds work, not just messages”A saved message list tells you what the agent said. Harness also stores what it is doing: turns, model requests, tool arguments, approval decisions, and outcomes. These structured objects form the session’s shared document.
For the notes.txt task, a read request and its arguments enter that document. If authorization requires your approval, the terminal displays a prompt from the request. Once allowed, the daemon runs the tool and records its result on the same request. The terminal renders that state; it does not reconstruct work by parsing transcript lines.
Read request and arguments │ ▼Authorization decision ▲ client approval, if required │ ▼Daemon runs allowed read │ ▼Result recorded on request └─ client displays outcomeTwo clients see one pending request and its eventual outcome, not two independently maintained conversations. The session is shared work state as well as conversation history.
The objects are TypeScript models backed by a Yjs CRDT document. A CRDT lets replicas merge changes. Plexus connects those models to reactive local views; the daemon supplies execution and authorization. Merging state does neither of those jobs, and it does not make filesystem effects transactional.
Where each part belongs
Section titled “Where each part belongs”The kernel holds configured connections, credentials, installed plugins, and defaults. A project supplies workspace-specific settings. A session has its own document for the conversation and work. An Agent in that document holds saved instructions and points to the current turn; the turn holds the requests needed to answer a prompt.
Kernel + project defaults │ seed settings ▼Session document contains Agent │ points to ▼ current turn ├─ model requests and outcomes ├─ tool requests and results ├─ queued work └─ link to previous turn → …For the main agent and delegated agents alike, runtime code handles each model request, talks to the model service, and records the outcome. A delegated worker has its own Agent and session document, but uses the same request mechanism within the daemon, not a separate worker process. How a turn runs follows one prompt through these objects; Agents and delegation follows a request into a worker’s conversation.
Closing the terminal and recovering work
Section titled “Closing the terminal and recovering work”Closing the terminal disconnects a client; it leaves the daemon process running. An ordinary session parks once no client is connected to its document or advertising that it is viewing the session. Parking stops ordinary interpretation and keeps the document for reattachment.
For ordinary conversational work, parking cancels in-flight interpretation: it aborts a model request and kills a running shell command. It keeps the turn and recorded requests, so parking is not the same as finishing the turn. An MCP request already sent to its server is allowed to settle instead of being cancelled.
A program submitted through the CLI’s separate eval path has another rule: its active evaluation and inner tool calls can finish after the client leaves. This exception applies to an eval turn, not every model-written scheme_repl program. Closing a window therefore does not stop every external operation in the same way.
To keep a session interpreting without a client, run /agentic true. /background enables that behavior and exits the TUI. The saved setting is agent.spec.daemon. These commands change the session’s eligibility to run; they do not start a second daemon process.
A daemon crash is different from a client disconnect. The document is persisted on disk, but the files, child processes, and external services it works with are outside that document. A tool can perform an operation and crash before its result is saved.
On restart, an external operation with recorded execution intent but no recorded outcome is marked unknown, rather than automatically replayed. Interrupted file writes and shell commands are among these operations. The next CLI launch starts a daemon if needed; attaching a stored session triggers recovery. Work that had not started can then be dispatched. Programs and delegated requests have additional recovery rules in the implementation sources below; recovering their records does not make interrupted external effects replayable. A missing receipt proves neither that an effect happened nor that it was absent. Before retrying an unknown operation, inspect the affected file or external service to establish what changed; do not assume retrying is harmless.
Implementation sources
Section titled “Implementation sources”Paths are relative to the Harness repository. The TUI startup path is packages/harness-server/src/ensure.ts and packages/harness/src/tui/host.ts. Occupancy and parking are implemented by KernelDaemon.ts, SessionDaemon.ts, and SessionOrchestrator.ts under packages/harness-server/src/daemon/; in-flight work handling is in packages/harness-session-runtime/src/park.ts.
The shared models are in packages/harness-model/src/session/Agent.ts and SessionRoot.ts. Recovery follows packages/harness-model/src/session/jobs/effects-recovery.ts and packages/harness-server/src/daemon/intent-recovery.ts. This page describes the current TUI startup and recovery paths.