Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Claude session JSONL files can exceed 5MB in practice. The FileSystemService currently enforces a 5MB read limit, causing session loading to fail with EXCEEDS max file size errors.

Changes

  • ClaudeCodeSessionService: Pass disableLimit: true when reading session files

    // Before
    const content = await this._fileSystem.readFile(fileUri);
    
    // After  
    const content = await this._fileSystem.readFile(fileUri, true);
  • MockFileSystemService: Add disableLimit parameter to match interface signature

  • Test: Validate loading 6MB session files (6000 messages)

Original prompt

This section details on the original issue you should resolve

<issue_title>Error: [FileSystemService] file:///Users/tyleonha/.claude/projects/-Users-tyleonha-Code-Microsoft-vscode-copilot-chat-2/803b9cb6-9b94-4893-9100-19c47978ec9b.jsonl EXCEEDS max file size. FAILED to read 6MB > 5MB</issue_title>
<issue_description>```
2026-01-25 22:33:44.076 [error] Error: [FileSystemService] file:///Users/tyleonha/.claude/projects/-Users-tyleonha-Code-Microsoft-vscode-copilot-chat-2/803b9cb6-9b94-4893-9100-19c47978ec9b.jsonl EXCEEDS max file size. FAILED to read 6MB > 5MB
at assertReadFileSizeLimit (/Users/tyleonha/Code/Microsoft/vscode-copilot-chat/src/platform/filesystem/common/fileSystemService.ts:73:10)
at VSCodeFileSystemService.readFile (/Users/tyleonha/Code/Microsoft/vscode-copilot-chat/src/platform/filesystem/vscode/fileSystemServiceImpl.ts:28:3)
at ClaudeCodeSessionService._getMessagesFromSession (/Users/tyleonha/Code/Microsoft/vscode-copilot-chat/src/extension/agents/claude/node/claudeCodeSessionService.ts:340:20)
at ClaudeCodeSessionService._getMessagesFromSessionWithUri (/Users/tyleonha/Code/Microsoft/vscode-copilot-chat/src/extension/agents/claude/node/claudeCodeSessionService.ts:332:18)
at async Promise.allSettled (index 46)
at ClaudeCodeSessionService._loadSessionsFromDisk (/Users/tyleonha/Code/Microsoft/vscode-copilot-chat/src/extension/agents/claude/node/claudeCodeSessionService.ts:222:19)
at ClaudeCodeSessionService.getAllSessions (/Users/tyleonha/Code/Microsoft/vscode-copilot-chat/src/extension/agents/claude/node/claudeCodeSessionService.ts:117:26)
at ClaudeChatSessionItemProvider.provideChatSessionItems (/Users/tyleonha/Code/Microsoft/vscode-copilot-chat/src/extension/chatSessions/vscode-node/claudeChatSessionItemProvider.ts:40:20)
at iS.$provideChatSessionItems (file:///Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:144:66118): [ClaudeChatSessionItemProvider] Failed to load session: file:///Users/tyleonha/.claude/projects/-Users-tyleonha-Code-Microsoft-vscode-copilot-chat-2/803b9cb6-9b94-4893-9100-19c47978ec9b.jsonl


We should handle big files fine.</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Pass disableLimit: true when reading Claude session files
- Update MockFileSystemService to accept disableLimit parameter
- Add test for large session files (>5MB)

Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix file size exceeded error in FileSystemService Fix: Allow reading large Claude session files by disabling size limit Jan 26, 2026
Copilot AI requested a review from TylerLeonhardt January 26, 2026 07:09
Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the immediate problem but we should lazily load these.

@TylerLeonhardt TylerLeonhardt marked this pull request as ready for review January 26, 2026 07:54
Copilot AI review requested due to automatic review settings January 26, 2026 07:54
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 26, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables loading Claude session .jsonl files larger than the platform IFileSystemService 5MB read limit by opting out of the size guard during session load.

Changes:

  • Pass disableLimit=true when reading Claude session files in ClaudeCodeSessionService.
  • Update MockFileSystemService.readFile signature to accept the optional disableLimit parameter.
  • Add a unit test intended to validate loading a >5MB session file.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/extension/agents/claude/node/claudeCodeSessionService.ts Reads session files with disableLimit=true so large session JSONL files load successfully.
src/platform/filesystem/node/test/mockFileSystemService.ts Aligns mock readFile signature with IFileSystemService’s optional disableLimit parameter.
src/extension/agents/claude/node/test/claudeCodeSessionService.spec.ts Adds a test that constructs and loads a ~6MB session file.

Comment on lines +91 to +96
mockFs.mockDirectory(dirUri, [[fileName, FileType.File]]);
mockFs.mockFile(URI.joinPath(dirUri, fileName), largeFileContents, 1000);

// Should not throw an error for large files
const sessions = await service.getAllSessions(CancellationToken.None);

Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new “large session file” test doesn’t currently validate the regression it’s meant to cover: MockFileSystemService.readFile doesn’t enforce the 5MB limit, so this test would have passed even before the production change. To make this test meaningful, either (a) make the mock apply the same size check unless disableLimit is true (e.g. reuse assertReadFileSizeLimit), or (b) assert via a spy that readFile was called with disableLimit=true when loading sessions.

Copilot uses AI. Check for mistakes.
}

async readFile(uri: URI): Promise<Uint8Array> {
async readFile(uri: URI, disableLimit?: boolean): Promise<Uint8Array> {
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mock readFile signature was updated to accept disableLimit, but the parameter isn’t used and the mock still doesn’t emulate the real 5MB read limit. Since the new behavior depends on bypassing that limit, consider applying the same limit logic in this mock (and honoring disableLimit) so unit tests can catch regressions around large-file reads.

Copilot uses AI. Check for mistakes.
Comment on lines +340 to +341
// Claude session files can be large (>5MB), so we disable the size limit
const content = await this._fileSystem.readFile(fileUri, true);
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing disableLimit=true removes the 5MB safeguard for these session files. Since this code auto-loads all *.jsonl sessions, a very large/corrupted file could now cause high memory usage or extension host instability. Consider adding a separate (higher) hard cap for session files (and/or a streaming reader) so “large but reasonable” files work while still protecting against extreme sizes.

Copilot uses AI. Check for mistakes.
@TylerLeonhardt TylerLeonhardt added this pull request to the merge queue Jan 26, 2026
Merged via the queue into main with commit ce0797b Jan 26, 2026
25 checks passed
@TylerLeonhardt TylerLeonhardt deleted the copilot/fix-file-size-exceeded-error branch January 26, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants