Skip to content

(triggers): a trigger to a background (daemon) session is refused as "session not found" #495

Closed

Description

@devsuitup

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 on main since 07/10 and unreleased. The log shows e7abbcdc opened twice on 08/10 (22:22:11 and 22:23:10, MCP server started) and never reaching a running TUI (no CLI 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 in activeSessions under the job's own session id (public/agents-view.js attachBgAgent → open-terminal → main.js session record with isAttach), so the lookup would find it and write into the claude attach PTY. 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 a claude attach client are unmeasured. Without an attach tab open, the result stays "session not found".

Expected

  1. A trigger whose target is a live kind: "bg" descriptor with no attach tab should say so (error: "background session, not attached here", with the jobId), not "session not found": the caller can then fall back instead of retrying.
  2. 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.
  3. 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 /compact reaches 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

  1. devsuitup commented on Oct 9, 2026

    @devsuitup
    OwnerAuthor

    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.md and in a test that pins it, and never reword it afterwards. Proposed: error: "background session, not attached here" with jobId and submitted: "no".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions