Repository navigation
(triggers): a trigger to a background (daemon) session is refused as "session not found" #495
Description
What happens
A trigger addressed to a session that runs as a background job of the Claude daemon (kind: "bg" in ~/.claude/sessions/<pid>.json) is answered {"ok":false,"error":"session not found","submitted":"no"}, even while the user looks at that session in a Switchboard window.
Measured on the installed app (v0.0.89, single instance, pid 10772, running since 04/10 18:50) in main.log:
[2026-10-06 21:23:30.423] [warn] [trigger-watcher] Session not found: e7abbcdc-86dd-439d-8232-f890f3aa05bc
[2026-10-08 04:19:28.510] [warn] [trigger-watcher] Session not found: e7abbcdc-86dd-439d-8232-f890f3aa05bc
[2026-10-08 21:08:33.724] [warn] [trigger-watcher] Session not found: e7abbcdc-86dd-439d-8232-f890f3aa05bc
[2026-10-09 10:08:25.089] [warn] [trigger-watcher] Session not found: e7abbcdc-86dd-439d-8232-f890f3aa05bc
The target: descriptor 22832.json, kind: "bg", jobId: "e7abbcdc", entrypoint: "cli", status busy. Four /compact chains written by harness contexte maintenant --session e7abbcdc-…, four refusals; the user compacted by hand.
Why
trigger-context.js resolves the target as activeSessions.get(sessionId) with !session.exited: a trigger reaches only a PTY Switchboard spawned itself under that session id. A background job's process belongs to the daemon; Switchboard never spawned it.
- On v0.0.89 there is no path at all: the Agents view and
claude attach((agents): a view of the sessions the claude daemon runs in the background #374) are onmainsince 07/10 and unreleased. The log showse7abbcdcopened twice on 08/10 (22:22:11 and 22:23:10, MCP server started) and never reaching a running TUI (noCLI connected, no altscreen, no OSC 9), so the entry is exited or absent when a trigger arrives. - On
main, an attach tab opened from the Agents view is registered inactiveSessionsunder the job's own session id (public/agents-view.jsattachBgAgent→open-terminal→main.jssession record withisAttach), so the lookup would find it and write into theclaude attachPTY. Nothing tests a trigger against an attach tab: readiness, busy flag and the compaction evidence of (triggers): require compaction evidence before confirming /compact (#488) #491 against aclaude attachclient are unmeasured. Without an attach tab open, the result stays "session not found".
Expected
- A trigger whose target is a live
kind: "bg"descriptor with no attach tab should say so (error: "background session, not attached here", with thejobId), not "session not found": the caller can then fall back instead of retrying. - With an attach tab open, the chain must work end to end through
claude attach, with the (triggers): require compaction evidence before confirming /compact (#488) #491 evidence (compaction_observed) proven by a test that drives the attach PTY. - To decide: whether Switchboard should open the attach itself (headless
claude attach <jobId>in a hidden PTY, detached after the chain) when no tab is open. That is the only way a scheduled/compactreaches a background session without a user present.
Out of scope
The harness side (fall back to advice when the result is a refusal for a bg session) is a harness board card.
Activity
devsuitup commentedon Oct 9, 2026
The harness side (claude-harness-lite card #449) will match the exact error string of the background-session refusal to turn it into advice (exit 2). The fix must therefore name that string once, in the result, in
docs/automation.mdand in a test that pins it, and never reword it afterwards. Proposed:error: "background session, not attached here"withjobIdandsubmitted: "no".(triggers): pin the refusal of a trigger to a background session (#495)
(triggers): name the background session a trigger cannot reach, deliv…
(triggers): pin the getLiveDescriptor wiring of the trigger context (#…
(triggers): name the background session a trigger cannot reach, verif…