Skip to content

fix: hide SDK stream-json sessions from the session list - #172

Open
Alexander-kniit wants to merge 1 commit into
graykode:mainfrom
Alexander-kniit:fix/skip-sdk-stream-sessions
Open

fix: hide SDK stream-json sessions from the session list#172
Alexander-kniit wants to merge 1 commit into
graykode:mainfrom
Alexander-kniit:fix/skip-sdk-stream-sessions

Conversation

@Alexander-kniit

Copy link
Copy Markdown

Problem

abtop surfaces every live claude process. That includes non-interactive sessions driven over the Agent SDK's bidirectional stream-json protocol (--input-format stream-json) — background infrastructure, not interactive agent sessions the user is running.

Concretely: claude-mem's "observer" holds such an SDK session open continuously. On Linux it shows up permanently in the sessions, projects, and context panels, and — because abtop reads each live claude proc's CLAUDE_CONFIG_DIR from /proc/<pid>/environ — it also registers the observer's transient config dir as a scanned config root, producing a phantom project row. Any tool built on the Agent SDK (CI agents, background summarizers, etc.) causes the same clutter.

Fix

This mirrors the filter abtop already has for its own claude --print summary children (is_descendant_of):

  • Add process::is_sdk_stream_session(cmd) — true only when the cmdline carries --input-format stream-json (space or = form).
  • Skip such procs at the two sites that gate on live claude procs:
    • find_claude_pids → removes the live session row
    • the /proc-environ config-root discovery loop → stops the SDK session's CLAUDE_CONFIG_DIR from being added as a scanned root (removes the phantom project row)

Why --input-format stream-json specifically

A human claude --print "q" never feeds an input stream--input-format stream-json is exclusively the programmatic SDK/bidirectional protocol. So this preserves the existing, deliberate behavior of surfacing user-launched --print sessions (see the comment on find_claude_pids): interactive and one-shot --print sessions are still shown unchanged. Only programmatic stream-json driven sessions are hidden.

Tests

  • is_sdk_stream_session_matches_stream_json_input — matches both arg forms; rejects interactive, --print, and --output-format stream-json-only cmdlines.
  • test_find_claude_pids_excludes_sdk_stream_sessions — an SDK observer proc is filtered; an interactive session and a human claude --print one-shot are still surfaced.

cargo test --lib → 202 passed, 0 failed.

Scope

Live-proc discovery is Linux-only in abtop (non-Linux read_env_var_from_proc is a stub), so this affects the Linux path where the clutter actually appears; behavior on other platforms is unchanged.

abtop surfaces every live `claude` process, including non-interactive
sessions driven over the Agent SDK's bidirectional stream-json protocol
(`--input-format stream-json`). These are background infrastructure, not
interactive agent sessions the user is running — for example claude-mem's
observer holds such a session open continuously, cluttering the sessions,
projects, and context panels, and even registers its transient
CLAUDE_CONFIG_DIR as a scanned config root.

This mirrors the existing filter that skips abtop's own `claude --print`
summary children: add `process::is_sdk_stream_session`, which matches only
the programmatic stream-json *input* protocol, and skip such procs in both
`find_claude_pids` (the live row) and the `/proc`-environ config-root
discovery loop (the dynamically-discovered historical row).

A human `claude --print "q"` never feeds an input stream, so interactive
and one-shot `--print` sessions are still surfaced unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant