Skip to content

session-flow: observer mod with live checks and session-start catch-up, replacing the detached observer #18959

Backlog

Description

@kyle-sexton

User story

As the owner, I want every Claude Code session watched for process mistakes while it runs, with findings written to the running-retro ledger and offered to me above the prompt, so retro and /corrections:codify happen without me remembering to run them, and without a long-lived background process polling the transcript.

Decisions (owner, 2026-11-24, "go w/ recommendations")

  • Q1, what runs: a session-flow mod with live checks that write findings to the ledger as they happen, plus a catch-up at the next session's start that runs the existing post-session analysis only for sessions that got no live checks (headless -p lanes, short sessions). The detached observer (observer.py tailer, 5 s polls, up to 24 h per session, 15 min idle end) is retired in the same change, per ADR 0052 "one implementation of a behavior at a time".
  • Q2, when it checks: on the model-step trigger the built-in side agent uses (every 6th model step within a turn, step index above 0), plus one check at the end of each turn that ran tools.
  • The built-in side agent (cc-plugin-you-should-know) stays on; ours serves a different purpose and must not repeat its notes.

Design inputs

  • Mechanism to model, read from the mods docs (https://code.claude.com/docs/en/plugins/mods/overview and its reference, api, events and interface pages) and from the built-in side agent's design as shipped in Claude Code 2.1.331 (study only; it is Anthropic's proprietary code, copy none of it):
    • trigger on turn.step (and turn.complete for the end-of-turn check), one check in flight per session, a reply that arrives after the turn moved on is dropped;
    • the check is $.model.fork with a prompt only: it reuses the main thread's cached request, has no tools, and writes nothing to the transcript;
    • the reply defaults to "none" in labeled lines, parsed leniently with a length cap;
    • repeats suppressed through a $.store-backed seen list injected into the prompt plus a normalized match;
    • backoff after findings the person ignores; any answer resets it;
    • delivery is an above-prompt band with digit hotkeys; "send to main session" uses $.prompt.fill; nothing reaches the main context unless sent.
  • Differences for our purpose: a closed category list (process mistake, regression against an owner decision, skipped verification, instruction drift), each finding written to the running-retro ledger with session, turn, step, category and the rule it cites; the prompt reads the owner-decision sources the repo names; findings persist off-context.
  • Catch-up: session.start lists ended sessions with no ledger and no live checks (a $.store set of handled session ids, an atomic lock in the launched process since $.store get/set is not atomic), honors observer_min_lines, and starts the analysis through $.process.run of a detaching launcher. Probe first whether a child started that way outlives the session; if not, the catch-up runs in the next session's lifetime.
  • Recursion guard: mods load in claude -p, so the catch-up's analysis run must not re-trigger the mod (an env marker).
  • Cost: every live check bills the session's account with no per-call cap; record each check's usage (as feat(session-flow): skip the observer's analysis for short sessions and record its usage #18951 does for the post-session run) so a day's cost can be read.

Acceptance criteria

  • Probe recorded: does a process started by $.process.run from a mod outlive the session (yes/no, Claude Code version).
  • Live check fires on every 6th model step of a turn and at the end of a tool-using turn, never twice at once, and drops stale replies; tests prove each.
  • A finding appears in the band and in the running-retro ledger; "send to main session" fills the prompt; nothing enters the main context otherwise.
  • Repeats across sessions are suppressed; ignored findings back off.
  • Catch-up analyzes an ended session that had no live checks and skips one that had them or is under observer_min_lines.
  • The detached observer path (observer-arm.sh SessionStart arm, observer.py tailer) is removed in the same PR, with docs and observer_* options migrated or retired.
  • Each live check's usage is recorded.
  • Cost measured before defaults: the end-of-turn trigger fires on most turns of a working session (most turns use tools), close to a check every turn. Ship both triggers as settings; measure per-check usage and checks per hour on one real working session with both on; turn the end-of-turn trigger on by default only if that cost is acceptable to the owner, otherwise default it off (the step trigger alone matches the built-in side agent).

Affected area / component

plugins/session-flow (new mod; running-retro, observer reference, hooks), ADR 0052 conformance.

Activity

  1. added
    session-owned
    on Nov 25, 2026
  2. kyle-sexton commented on Nov 25, 2026

    @kyle-sexton
    MemberAuthor

    Status as of 2026-11-25, after #18976 merged (aac921da82cb).

    • Probe: yes. A setsid -f child started from a mod's $.process.run in a claude -p --plugin-dir run on Claude Code 2.1.332 kept running 41 s after the session exited. Mods also load under -p, so the recursion guard (SESSION_FLOW_OBSERVER_ANALYSIS) is needed and is in place.
    • Live check on every 6th model step and at the end of a tool-using turn, one at a time, with stale replies dropped; tested in plugins/session-flow/hooks/observer-live.test.ts.
    • Each finding goes to the band and the running-retro ledger. Send fills the prompt; nothing enters the main context otherwise.
    • Repeats across sessions are suppressed, and ignored findings back off.
    • Catch-up analyzes an ended session that had no live checks, and skips one that had them or is under observer_min_lines. A failed run is retried once, and a resumed follow-up is analyzed.
    • The detached observer (the observer-arm.sh arm and the observer.py tailer) is removed, along with observer_poll_seconds, observer_max_seconds and the arm actions.
    • Each live check's usage is recorded in <plugin data>/session-flow-observer/live-<session>.jsonl.
    • Cost measured before defaults. observer_turn_end_check ships off. Next: once the release is installed, run one working session with both triggers on, then report per-check usage and checks per hour from the usage file to the owner, who decides the end-of-turn default.

    One design note: the catch-up stays a SessionStart settings hook rather than a $.process.run from the module. The hook already has the guards, the platform shim and the Python probe, and the probe shows either launcher outlives the session.

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

    session-owned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions