claude-code - 💡(How to fix) Fix Agents cannot self-report their resume command -- --resume exists but agents don't know their own session ID [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52262Fetched 2026-04-24 06:11:51
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

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.

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.

RAW_BUFFERClick to expand / collapse

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:

  1. Knowing that --resume exists (agents often don't)
  2. Knowing the current session's UUID (agents have no direct introspective access to this)
  3. 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

  1. Start any agent session with claude --agent <name> --resume <id>
  2. Ask: "What is my resume command if I need to reattach to this session?"
  3. Observe incorrect or incomplete answer

extent analysis

TL;DR

Exposing the session ID via an environment variable or adding a slash command to retrieve the resume command could fix the issue.

Guidance

  • The root cause is the lack of an introspective API for agents to retrieve their own session ID, making it difficult for them to provide the correct resume command.
  • To verify the issue, start an agent session with claude --agent <name> --resume <id> and ask the agent for its resume command.
  • A potential workaround is to manually run a filesystem command to list JSONL files and infer the active session ID from the modification time.
  • Agents could be modified to parse the JSONL filename to extract the session ID, but this approach is fragile and prone to errors.

Example

No code snippet is provided as the issue does not imply a specific code change, but rather a design or API change to expose the session ID.

Notes

The proposed solutions, such as exposing the session ID via an environment variable or adding a slash command, would require changes to the agent's implementation or the underlying system.

Recommendation

Apply a workaround, such as manually running a filesystem command to list JSONL files, until a more robust solution, like exposing the session ID via an environment variable, is implemented. This is because the current approach is error-prone and time-consuming, especially in multi-agent setups.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Agents cannot self-report their resume command -- --resume exists but agents don't know their own session ID [1 comments, 2 participants]