Skip to content

fix: session output returns stale cache after /clear#477

Open
lshoravi wants to merge 1 commit intoasheshgoplani:mainfrom
lshoravi:fix/stale-output-after-clear
Open

fix: session output returns stale cache after /clear#477
lshoravi wants to merge 1 commit intoasheshgoplani:mainfrom
lshoravi:fix/stale-output-after-clear

Conversation

@lshoravi
Copy link
Copy Markdown

@lshoravi lshoravi commented Apr 2, 2026

Hi, thanks for the great application. I'm submitting some stuff I changed locally, in case you want it upstream. (PR 2/3)

Summary

  • session output returned the pre-/clear response because GetLastResponseBestEffort() read from the old JSONL file (which still exists on disk) before checking whether a newer session file was available
  • Move session ID sync (tmux env + disk scan via syncClaudeSessionFromDisk) to run before the first read attempt, not as a fallback after failure

Root cause

After /clear, Claude Code creates a new session UUID on disk. The stored ClaudeSessionID still pointed to the old file. getClaudeLastResponse() read the old file successfully, so the recovery paths (syncClaudeSessionFromDisk) never executed.

Test plan

  • New test TestGetLastResponseBestEffort_ReturnsNewSessionAfterClear: sets up old + new JSONL files, points ClaudeSessionID at the old one, verifies GetLastResponseBestEffort returns the new content
  • Manual: run /clear on a waiting session, let it complete a new task, verify agent-deck session output <session> -q returns the new response

GetLastResponseBestEffort() read the JSONL file at the stored
ClaudeSessionID, which succeeded with stale data because the pre-/clear
file still exists on disk. The recovery paths (syncClaudeSessionFromDisk)
only ran on error, so the newer session file was never discovered.

Move session ID sync (tmux env + disk scan) to run proactively before
the first read attempt, not as a fallback after failure.

Closes: stale output after /clear
lshoravi added a commit to lshoravi/agent-deck that referenced this pull request Apr 2, 2026
@lshoravi lshoravi marked this pull request as ready for review April 2, 2026 21:23
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