Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 76. An assistant chat thread lives only in the memory of the daemon

Status: accepted. Decided 2026-12-01 by the owner (issue #232).

## Context

A person chats with the assistant about a flow (ADR 61). The daemon keeps
a thread for each chat: the harness session, the agent, the last 20
exchanges, the runs the chat talked about, and whether a message is in work.
The thread store keeps at most 100 threads. It forgets a thread after six
hours without a message, and it forgets the thread used longest ago when
it is full.

The browser keeps the messages that the person sees. A message with a
thread id that the daemon does not know starts a new thread and a new
harness session.

## Decision

1. **A chat thread lives only in the memory of the daemon.** No table
holds it, and sync does not carry it to another Device.
2. **A thread is a working conversation, not a record.** The record of
what an agent did is the run and its event log. A chat only helps a
person build a flow, and a person applies each proposal (ADR 61).
3. **Memory is cheap.** A store in the database needs a schema, a
migration, a sync rule and a clean-up of old threads. The store in
memory needs none of these.

## Consequences

- A restart of the daemon loses every open thread. The next message in
such a chat starts a new harness session. The agent then does not know
the earlier exchanges, but the person still sees them in the browser.
- A run stays a run. Only the chat about it is lost to the agent.
- A chat does not move to another Device or to the phone.
- The cost record of an Improver chat after a restart counts as the
request says (`docs/steering/TECH.md`, "A chat that became the
Improver's stays the Improver's in the cost record").

## When to look at this again

- People lose a chat in work after a restart or an update, and they
say so.
- A chat must continue on another Device or on the phone.
- A thread must be an audit record, for example to show who proposed a
change to a flow.
- A chat must live longer than six hours without a message.

## Where

- `packages/daemon/src/assistant/threads.ts`
- `packages/daemon/src/assistant/assistant.ts`
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { describe, expect, test } from "bun:test";
import { OPENCODE_FACTS } from "./opencode";

describe("the OpenCode take-over command", () => {
test("opens the session by its id in the OpenCode screen", () => {
expect(OPENCODE_FACTS.takeOver?.("ses_1")).toBe("opencode --session ses_1");
});
});
Loading