Repository navigation
Open
Labels
ai-analyzedAI automation workflow has run an analysis of this issue and provided a comment.ai-generatedGenerated by AI automation workflowsbugIssue identified by VS Code Team member as probable bugerror-telemetryVS Code - Issues generated by telemetryrecent-regressionstable-anomaly
Description
Error Message
unhandlederror-PerfSampleError: by <<renderer>> in (anonymous)#workbench.desktop.main.js:414:16444
Stack Trace
at (anonymous) (./src/vs/base/common/objects.ts:172:28)
at safeStringify (./src/vs/base/common/objects.ts:170:16)
at saveCachedSessions (./src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsModel.ts:888:0)
at (anonymous) (./src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsModel.ts:534:0)
at _deliver (./src/vs/base/common/event.ts:1352:9)
at _deliverQueue (./src/vs/base/common/event.ts:1371:9)
at fire (./src/vs/base/common/event.ts:1384:1)
at flush (./src/vs/platform/storage/common/storage.ts:614:7)
at focus (./src/vs/workbench/browser/workbench.ts:259:46)
Raw Stack Trace (minified)
at (anonymous) (out/vs/workbench/workbench.desktop.main.js:414:16444) at WO (out/vs/workbench/workbench.desktop.main.js:414:16402) at saveCachedSessions (out/vs/workbench/workbench.desktop.main.js:1075:2676) at (anonymous) (out/vs/workbench/workbench.desktop.main.js:1074:2208) at _deliver (out/vs/workbench/workbench.desktop.main.js:405:3178) at _deliverQueue (out/vs/workbench/workbench.desktop.main.js:405:3306) at fire (out/vs/workbench/workbench.desktop.main.js:405:3399) at flush (out/vs/workbench/workbench.desktop.main.js:852:105978) at (anonymous) (out/vs/workbench/workbench.desktop.main.js:4909:114720) at _deliver (out/vs/workbench/workbench.desktop.main.js:405:3178) at _deliverQueue (out/vs/workbench/workbench.desktop.main.js:405:3306) at fire (out/vs/workbench/workbench.desktop.main.js:405:3399) at (anonymous) (out/vs/workbench/workbench.desktop.main.js:403:11761) at (anonymous) (out/vs/workbench/workbench.desktop.main.js:403:11919) at _deliver (out/vs/workbench/workbench.desktop.main.js:405:3178) at fire (out/vs/workbench/workbench.desktop.main.js:405:3399) at (anonymous) (out/vs/workbench/workbench.desktop.main.js:403:11562) at _deliver (out/vs/workbench/workbench.desktop.main.js:405:3178) at fire (out/vs/workbench/workbench.desktop.main.js:405:3399) at (anonymous) (out/vs/workbench/workbench.desktop.main.js:403:11761) at _deliver (out/vs/workbench/workbench.desktop.main.js:405:3178) at fire (out/vs/workbench/workbench.desktop.main.js:405:3399) at c (out/vs/workbench/workbench.desktop.main.js:1034:881) at onResponse (out/vs/workbench/workbench.desktop.main.js:1034:1713) at onBuffer (out/vs/workbench/workbench.desktop.main.js:1034:1409) at (anonymous) (out/vs/workbench/workbench.desktop.main.js:1033:1628) at _deliver (out/vs/workbench/workbench.desktop.main.js:405:3178) at _deliverQueue (out/vs/workbench/workbench.desktop.main.js:405:3306) at fire (out/vs/workbench/workbench.desktop.main.js:405:3399) at ke (out/vs/workbench/workbench.desktop.main.js:403:15279) at (anonymous) at emit (node:<REDACTED: user-file-path>:2:45640) at onMessage (node:<REDACTED: user-file-path>:2:121218)
Details
| Property | Value |
|---|---|
| Bucket ID | 82c96c3f-83a9-9a0d-5954-404a4184ad55 |
| Version | 1.118.1 |
| Commit | 034f571d |
| Last Seen | Mon May 04 2026 23:40:25 GMT+0000 (Coordinated Universal Time) |
| Platforms | Windows, Mac, Linux |
| Product | VSCode |
This issue was automatically created from the VS Code Errors Dashboard
Metadata
Metadata
Assignees
Labels
ai-analyzedAI automation workflow has run an analysis of this issue and provided a comment.ai-generatedGenerated by AI automation workflowsbugIssue identified by VS Code Team member as probable bugerror-telemetryVS Code - Issues generated by telemetryrecent-regressionstable-anomaly
Activity
vs-code-engineering commentedon May 5, 2026
Stable Release Anomaly Details
Related Buckets (coalesced)
82c96c3f(representative)a55719d8cde3b512a78b9c92Analysis
This is a performance regression in
agentSessionsModel.ts—safeStringify(objects.ts) is called duringsaveCachedSessionswhich serializes agent session state. This fires on storage flush (triggered by window focus), blocking the renderer.Key call path:
safeStringify (objects.ts)→saveCachedSessions (agentSessionsModel.ts:888)→event.fire→flush (storage.ts:614)→focus (workbench.ts:259)Combined, 477 users are affected across all related buckets. The session serialization becomes expensive as agent session data grows.
vs-code-engineering commentedon May 5, 2026
🔍 Error Investigation
Summary
The
PerfSampleErroris a performance profiling error thrown whensaveCachedSessions()callssafeStringify()(which wrapsJSON.stringify) to serialize agent session data during a storage flush triggered by window focus. The profiling system detects that the serialization takes too long on the main thread and fires the error as telemetry. The massive spike in 1.118.1 (1519 hits / 105 users vs 73 / 13 in 1.118.0) correlates with increased agent session usage and larger data payloads being serialized synchronously.Culprit Commit
This is a pre-existing performance issue, not a regression introduced by a single commit. The bucket shows hits as far back as v1.111.0 (March 2026), with a significant spike in v1.118.1. The spike is due to increased adoption of agent sessions resulting in larger data being serialized synchronously on the main thread during
onWillSaveState, not a specific code change that broke logic.Code Flow
sequenceDiagram participant Focus as "Window Focus" participant Storage as "StorageService.flush" participant Model as "AgentSessionsModel" participant Cache as "AgentSessionsCache" participant Stringify as "safeStringify" Focus->>Storage: focus event triggers flush Storage->>Model: onWillSaveState fires Model->>Cache: saveCachedSessions(sessions) Cache->>Stringify: safeStringify(serialized) Note over Stringify: JSON.stringify blocks main thread<br/>Profiler detects long execution<br/>PerfSampleError firedAffected Files
src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsModel.tssrc/vs/base/common/objects.tssafeStringify/JSON.stringifysrc/vs/platform/storage/common/storage.tsflush()firesonWillSaveStatesrc/vs/workbench/browser/workbench.tsRepro Steps
Fix Proposal
Fix location:
src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsModel.ts→saveCachedSessions()Approach: Reduce the amount of data serialized synchronously on the main thread. Options include:
metadataandchangesfields before serialization (e.g., only store summary counts for changes, truncate metadata)Recommended Owner
@bpasero— primary contributor toagentSessionsModel.ts(multiple recent commits including session caching, metadata, and architecture)fix: cap agent session cache serialization to prevent perf regression