Skip to content

Run the Nested-Session ID Probe Behind Requirement 9 #4312

Closed

Description

@ptr727

Problem

#2598's approved option asked for a nested claude -p run to check whether a nested Claude Code session inherits the parent's CLAUDE_CODE_SESSION_ID. The requirement 9 text #4311 landed in host-setup/agent-safety/README.md holds either way. But if the id is inherited, the Claude kit falls short of it: it names a nested session's command scopes for the parent, and the nested SessionEnd sweep stops the parent's own scopes.

A nested agent session is a live run outside an agent's own workspace, so no agent runs this probe. The maintainer runs it.

The probe

The exact command and the expected observations for both cases are in #4311's body, under "For the Maintainer to Run". Run it as one Bash tool call in a fresh, idle Claude Code session on a Linux host where the kit's containment prefix is registered.

Done looks like

  • The result is recorded here: whether tool= and env= print the nested session's own id or the parent's.
  • Own id: this issue closes with the result as its evidence.
  • Inherited id: this issue becomes the kit-defect fix, an edit under host-setup/agent-safety/claude/ that needs the maintainer's approval.

🤖 Generated with Claude Code

Activity

  1. ptr727 commented on Nov 22, 2026

    @ptr727
    OwnerAuthor

    Probe result, 2026-11-22: a nested session gets its own id. The maintainer had the probe run as a Bash tool call in an idle Claude Code session on a Linux host with the kit's containment prefix registered. Ids below are placeholders: <parent> is the outer session and <nested> is the claude -p session.

    • tool=<nested> and the SessionEnd hook's env=<nested> match each other and differ from parent=<parent>.
    • The hook's stdin payload carries "session_id":"<nested>".
    • root=<parent> in both the tool call and the hook.
    • The cgroup line names claude-tree-<parent>.slice/claude-tool-<nested>-<pid>-<token>.scope.
    • The outer command ran to its last cat, and claude -p exited 0.

    So requirement 9 holds as implemented, and there is no kit defect to fix.

    The probe text in #4311 is itself broken. --allowedTools takes more than one value, so the prompt after --allowedTools Bash is read as a second tool name. claude -p then exits with "Input must be provided either through stdin or as a prompt argument". The SessionEnd hook still fires, which is why the first run showed only the env= half. Putting -- before the prompt fixes it, and the result above is from that rerun.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions