A schedule's session opened from the store again is still offered report_write
ci / check (push) Canceled after 0s

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 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Fable 5.2 committed 2026-11-17 23:02:12 +00:00
1 parent d44fd46c00
commit 22143b1199
4 files changed
+42 -5

No files matched your search

+4
View File
@@ -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
+10 -3
View File
@@ -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<boolean>(id, SCHEDULED_META) === true) session.app.forgetful()
const kept = session.app.store?.meta<ScheduledTurn | true>(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)
+3 -2
View File
@@ -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
+25
View File
@@ -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")
})