From 22143b1199ec88427d4e257d126b2a8a2bb08271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Tue, 17 Nov 2026 23:02:12 +0000 Subject: [PATCH] A schedule's session opened from the store again is still offered report_write How a schedule opened its session (its notify-when among it) lived in the agent's memory only. After a restart of the service a continuing schedule's session came back from the store without it, and its next run was told to file a report with a tool it had not been given. It is kept in the session's meta now, where the mark that a schedule opened it already was. Co-Authored-By: Claude Fable 5.2 --- CHANGELOG.md | 4 ++++ src/acp/agent.ts | 13 ++++++++++--- src/session/store.ts | 5 +++-- tests/scheduled.test.ts | 25 +++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d8724e..f7007f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,10 @@ Harness spec 3.9.0: the model last used in a directory, the two types of schedul ### Fixed +- **A continuing schedule's run after the service restarted is offered `report_write` again.** + How a schedule opened its session was kept in memory only, so a session opened from the store + again — the service restarted, or the link dialled anew — had lost it: the next run's prompt + told the model to file a report with a tool it was not given. It is kept with the session now. - **`.env.example` is read without asking after a broad allow, as before it.** With `read: allow` made in a menu, by an "always" answer or in a project, the defaults' `*.env.*: ask` and `*.env.example: allow` both counted as narrower rules and the stricter won, so the allow diff --git a/src/acp/agent.ts b/src/acp/agent.ts index fdc7378..ff3f4b7 100644 --- a/src/acp/agent.ts +++ b/src/acp/agent.ts @@ -660,7 +660,9 @@ export class AcpAgent { markRemote(session.app.store, id) if (scheduled) { try { - session.app.store?.setMeta(id, SCHEDULED_META, true) + // How it was opened, kept with the session: opened from the store again — after a restart + // of the service — it is still a schedule's, with the tools it was opened with. + session.app.store?.setMeta(id, SCHEDULED_META, scheduled) } catch {} } // The client's chat: its memory calls land in that chat's data group (acp.md *Memory*). @@ -770,9 +772,14 @@ export class AcpAgent { session.app = createApp({ cwd: dir, ...(L ? { mode: L.maxMode } : {}), asker: this.asker(session), modelTitles: false, resuming: id }) session.app.resume(id) markRemote(session.app.store, id) - // A schedule's session stays one: nothing in it becomes its directory's model. + // A schedule's session stays one: nothing in it becomes its directory's model, and its list + // of tools is the one it was opened with — report_write for a schedule that notifies + // (reports.md §2). `opened` used to live in memory only, so a continuing schedule's next run + // after a restart of the service was not offered the tool its prompt told it to call. try { - if (session.app.store?.meta(id, SCHEDULED_META) === true) session.app.forgetful() + const kept = session.app.store?.meta(id, SCHEDULED_META) + if (kept) session.app.forgetful() + if (kept && typeof kept === "object") session.opened = kept } catch {} session.app.setScope(id) if (L) session.app.engine.mode = clampMode(session.app.engine.mode, L.maxMode) diff --git a/src/session/store.ts b/src/session/store.ts index 0746ba5..d58a449 100644 --- a/src/session/store.ts +++ b/src/session/store.ts @@ -69,8 +69,9 @@ CREATE TABLE IF NOT EXISTS session_meta ( * acp/agent.ts, which re-exports it). Here, so the app can ask it too without importing the * agent, which imports the app. */ export const REMOTE_META = "remote" -/** Meta: a schedule opened this session for its run (harness acp.md, *Scheduled work*). Kept so - * that, opened from the store again, it still never becomes its directory's model. */ +/** Meta: a schedule opened this session for its run (harness acp.md, *Scheduled work*) — how it + * was opened (its notify-when among it). Kept so that, opened from the store again, it still + * never becomes its directory's model and is still offered report_write. */ export const SCHEDULED_META = "scheduled" /** The session_meta key holding the directory a session was started in: a session started diff --git a/tests/scheduled.test.ts b/tests/scheduled.test.ts index 3ab05a0..f42b319 100644 --- a/tests/scheduled.test.ts +++ b/tests/scheduled.test.ts @@ -273,3 +273,28 @@ test("notify never, and a server that says no notify at all: the tool is not in expect(bare(fake.requests[4].messages.at(-1).content)).toBe(TOOL_SPECS.report_write!.unavailable!) expect(mine._meta.lembas.scheduled).toBeUndefined() }) + +test("a continuing schedule's session opened from the store again — the service restarted — is still offered report_write", async () => { + fake = fakeProvider([ + { chunks: [delta({ content: "Nothing to tell." })] }, + { chunks: [toolCall(0, "c1", "report_write", R())] }, + { chunks: [delta({ content: "Filed." })] }, + { chunks: [delta({ content: "It was the disk." })] }, + ]) + config(fake.url) + const root = project() + const scheduled = sched({ notify: "when" }) + const first = await client(limitsFor(root)) + const s: any = await first.c.request("session/new", { cwd: root, _meta: { lembas: { scheduled } } }) + await first.c.request("session/prompt", { sessionId: s.sessionId, prompt: [{ type: "text", text: "check" }], _meta: { lembas: { turnId: "run7", scheduled } } }) + expect(toolNames(0)).toContain("report_write") + // Another link, with nothing in memory: the session comes from the store. + const again = await client(limitsFor(root)) + const next = sched({ notify: "when", run_id: "run8" }) + const r: any = await again.c.request("session/prompt", { sessionId: s.sessionId, prompt: [{ type: "text", text: "check" }], _meta: { lembas: { turnId: "run8", scheduled: next } } }) + expect(toolNames(1)).toContain("report_write") + expect(r._meta.lembas.scheduled.report).toMatchObject({ title: "Disk almost full" }) + // …and the person's own turn in it still finds the tool there, and unavailable. + await again.c.request("session/prompt", { sessionId: s.sessionId, prompt: [{ type: "text", text: "what was it?" }] }) + expect(toolNames(3)).toContain("report_write") +})