Problem
Since #166, resolvePtyEnv (src/pty/createPty.ts) sets AGENT_TTY_ACTIVE=true for every PTY and sets AGENT_TTY_SESSION_ID only when a sessionId is passed. When no sessionId is passed, an AGENT_TTY_SESSION_ID inherited from the parent environment goes through unchanged.
The only caller without a sessionId is the doctor PTY-spawn probe (src/cli/commands/doctor.ts, deps.createPty({...}) around line 472). So when doctor runs inside an agent-tty session, its throwaway probe process gets:
AGENT_TTY_ACTIVE=true, although it is not a managed session, and
- the outer session's
AGENT_TTY_SESSION_ID.
The impact is low because the probe is short-lived. But the environment contract documented in docs/USAGE.md ("a session reports its own ID") doesn't hold for PTYs without a session.
Expected
A PTY spawned without a sessionId must not claim a session. It should drop inherited AGENT_TTY_SESSION_ID and AGENT_TTY_ACTIVE rather than passing the outer values through. Explicit --env/caller env values should still win, matching the existing precedence.
Acceptance
Follow-up from #166.
Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high
Problem
Since #166,
resolvePtyEnv(src/pty/createPty.ts) setsAGENT_TTY_ACTIVE=truefor every PTY and setsAGENT_TTY_SESSION_IDonly when asessionIdis passed. When nosessionIdis passed, anAGENT_TTY_SESSION_IDinherited from the parent environment goes through unchanged.The only caller without a
sessionIdis thedoctorPTY-spawn probe (src/cli/commands/doctor.ts,deps.createPty({...})around line 472). So whendoctorruns inside an agent-tty session, its throwaway probe process gets:AGENT_TTY_ACTIVE=true, although it is not a managed session, andAGENT_TTY_SESSION_ID.The impact is low because the probe is short-lived. But the environment contract documented in
docs/USAGE.md("a session reports its own ID") doesn't hold for PTYs without a session.Expected
A PTY spawned without a
sessionIdmust not claim a session. It should drop inheritedAGENT_TTY_SESSION_IDandAGENT_TTY_ACTIVErather than passing the outer values through. Explicit--env/callerenvvalues should still win, matching the existing precedence.Acceptance
resolvePtyEnvwith nosessionIdremoves inheritedAGENT_TTY_SESSION_IDand does not setAGENT_TTY_ACTIVE=true, or a clearly argued alternative (for example, makingsessionIdrequired and givingdoctoran explicit opt-out).envstill wins, and existing session behavior is unchanged.resolvePtyEnvdoc comment anddocs/USAGE.mdmatch the behavior.Follow-up from #166.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high