diff --git a/docs/adr/0076-an-assistant-chat-thread-lives-only-in-the-memory-of-the-daemon.md b/docs/adr/0076-an-assistant-chat-thread-lives-only-in-the-memory-of-the-daemon.md new file mode 100644 index 000000000..423f68486 --- /dev/null +++ b/docs/adr/0076-an-assistant-chat-thread-lives-only-in-the-memory-of-the-daemon.md @@ -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` diff --git a/packages/agents/src/harness-drivers/facts-table/opencode.test.ts b/packages/agents/src/harness-drivers/facts-table/opencode.test.ts new file mode 100644 index 000000000..aa61de025 --- /dev/null +++ b/packages/agents/src/harness-drivers/facts-table/opencode.test.ts @@ -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"); + }); +});