Agents cannot self-report their resume command -- --resume exists but agents don't know their own session ID
Summary
When a user asks a running agent "what is my resume command?" or "how do I resume this session?", agents consistently fail to give the correct answer. This is a critical UX gap for multi-agent overnight workflows where users need to reattach to specific agent sessions after logging out.
Observed behaviors (all wrong)
Three different agents gave three different wrong answers when asked the same question:
- Agent 1: "You can't resume this exact session -- Claude Code sessions don't have a --resume flag." (False. --resume exists.)
- Agent 2: "Just run \
claude\in the project directory -- the compact recovery re-reads everything automatically." (Wrong. This starts a new session, not the same one.) - Agent 3 (after being corrected): Finally provided the correct command with the session ID pulled from the JSONL filename.
The correct answer requires:
- Knowing that --resume exists (agents often don't)
- Knowing the current session's UUID (agents have no direct introspective access to this)
- Knowing the agent type, model, and permission-mode flags to reconstruct the full launch command
Root cause
Agents have no introspective API to retrieve their own session ID. The session UUID lives in the JSONL filename under ~/.claude/projects/<project>/. The only way to find it is to run a filesystem command (Get-ChildItem / ls) and infer which file is the active one by mtime. This is fragile and unintuitive.
Impact
Users running multi-agent overnight pipelines (Opus PM + multiple Sonnet workers coordinating via filesystem handshake) need to reattach to specific worker sessions after logging out or switching terminals. Currently this requires:
- Asking the agent, getting a wrong answer
- Being corrected, asking again
- Running a PowerShell/bash command manually to list JSONL files
- Inferring the right UUID from mtime
In a 6-8 agent overnight setup, this wastes significant time every morning.
Requested fix
Agents should be able to answer "what is my resume command?" accurately. Options:
- Expose the session ID via an environment variable (CLAUDE_SESSION_ID) that agents can read via Bash
- Add a /session-id or /resume-command slash command
- Include the resume command in the session header that agents see at startup
Reproduction
- Start any agent session with
claude --agent <name> --resume <id> - Ask: "What is my resume command if I need to reattach to this session?"
- Observe incorrect or incomplete answer
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗