From b7bdf2258456e5c112f30d11b3a5ffba45ab04b7 Mon Sep 17 00:00:00 2001 From: xiduzo Date: Wed, 2 Dec 2026 10:13:09 +0100 Subject: [PATCH 1/2] docs(adr): ADR 76, an assistant chat thread lives only in the memory of the daemon The owner decided that chat threads stay in memory. The ADR records the reason, the loss of open threads at a restart, and when to look again. threads.ts holds no note about a later store. Closes #232 Co-Authored-By: Claude Opus 5.5 Co-authored-by: sander boer --- ...-lives-only-in-the-memory-of-the-daemon.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs/adr/0076-an-assistant-chat-thread-lives-only-in-the-memory-of-the-daemon.md 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` From 5a4ce43bf3493e7a084260774854d45f1a3f2d47 Mon Sep 17 00:00:00 2001 From: xiduzo Date: Wed, 2 Dec 2026 10:13:12 +0100 Subject: [PATCH 2/2] test(agents): pin the OpenCode take-over command opencode --session is right for OpenCode 2.0.22 (--session, -s: session id to continue) and was right for 1.x (v1.19.6 tui.ts: --session, -s, session id to continue). The command stays. take-over argv: test green at once, no fix needed. Closes #225 Co-Authored-By: Claude Opus 5.5 Co-authored-by: sander boer --- .../src/harness-drivers/facts-table/opencode.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 packages/agents/src/harness-drivers/facts-table/opencode.test.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"); + }); +});