[Bug]: VS Code extension shows incomplete conversation history after "Tool permission stream closed" error — session chain forks to a stale tool_use branch

Status Open
Reported on v2.1.259
Maintainer reply None cached
Activity 1 comment · opened Sep 4, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

After the VS Code extension was updated, two existing conversations became visibly incomplete in the extension UI — only a tiny fragment of each session was rendered — while the same sessions were fully intact when opened via claude --resume in the CLI.

Both affected sessions ended with this error visible in the UI:

Tool permission request failed: AbortError: Tool permission stream closed before response received

Root cause (verified by inspecting the session .jsonl files):

The last user record appended to each affected session file was this AbortError tool-result, but its parentUuid did not point to the previous message of the conversation. Instead it pointed to a stale assistant tool_use record from near the beginning of the file (a turn from roughly a day earlier), and the tool_use_id in the error result matched that old tool_use exactly. This created a fork in the message chain.

When rendering/restoring the conversation, the extension walks the parentUuid chain backwards from the last record. Since the last record is the orphaned error result, the walk follows the short forked branch and bypasses the entire main chain, so the UI shows almost nothing.

Measured in one session: main chain = 523 reachable records, chain walked from the final record = 9. Second session: 278 vs 217.

What Should Happen?

  1. A tool_result for a failed/restored permission request should be appended as a child of the current conversation tip, not of a stale historical tool_use, so it doesn't fork the message chain.
  2. Alternatively, chain reconstruction for display could handle forks gracefully (e.g., prefer the longest branch or the latest timestamps) instead of strictly following the last record's parent links.

Error Messages/Logs

Tool permission request failed: AbortError: Tool permission stream closed before response received

Steps to Reproduce

  1. In the VS Code extension, get into a state where a tool permission request is raised but never answered (e.g., close the VS Code window while the permission prompt is pending).
  2. Update the extension (observed across 2.1.259 → 2.1.260; CLI versions in use were 2.1.251–2.1.260).
  3. Reopen the session. The pending permission request fails with AbortError: Tool permission stream closed before response received, and the error tool_result gets appended to the file as a child of a stale historical tool_use.
  4. Session history in the extension UI is now mostly missing, though claude --resume in the CLI shows the session fully.

Workaround verified: re-parenting the final AbortError record (changing its parentUuid from the stale tool_use uuid to the uuid of the last assistant record on the main chain) restored full history after reloading VS Code. Chain length walked from the last record went from 9 → 524 and 217 → 279. Session data itself was never corrupted.

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.258 (approximate — the sessions rendered fine before the extension update to 2.1.259/2.1.260)

Claude Code Version

2.1.260 (VS Code extension, entrypoint claude-vscode; Windows x64)

Platform

Other

Operating System

Windows

Terminal/Shell

Other

Additional Information

The affected session files are only modified locally by the extension/CLI — no server-side interaction is involved.

Additional technical notes from inspecting the extension code (v2.1.260):

  1. When a session's transcript exceeds 5 MB, the extension skips content before the last compact boundary when loading (CLAUDE_CODE_DISABLE_PRECOMPACT_SKIP gates this). This is a separate mechanism and was NOT the cause here — one affected session was only 3.7 MB. Worth documenting in case other users hit incomplete history and assume this env var is related.
  1. Note for other users hitting similar symptoms ("CLI shows the conversation fine, extension shows only a fragment ending in the AbortError above"): the fix is to edit the session's .jsonl under ~/.claude/projects/<project-dir>/ — find the last record (the AbortError tool_result) and change its parentUuid to the uuid of the last assistant record on the main chain. Back up the file first.
  1. A related gotcha: the claudeCode.environmentVariables VS Code setting only injects env vars into CLI subprocesses spawned by the extension, not into the extension host process itself. Extension-host-level env gates like CLAUDE_CODE_DISABLE_PRECOMPACT_SKIP require setting a Windows user environment variable and fully restarting VS Code.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗