BitDiary

Back

现象

VSCode 中使用 Agent / Open in Agent 时:

第一轮对话正常:

你好

Agent 返回:

Considered greeting in Chinese and offering assistance
你好!👋

但第二轮对话时报错:

Error: Error during execution

同时:

  • Context Window 未超限
  • 38K / 200K token 左右
  • 新开聊天可能恢复正常
  • 部分 Agent 插件无法正常删除

根因分析

问题最终确认并非:

  • VSCode 本体问题
  • Token 超限
  • Prompt 问题
  • MCP 工具调用问题

而是:

workspaceStorage / globalStorage 中的 Agent 会话状态损坏

属于典型的:

conversation persistence corruption

关键异常信号

以下内容不应该出现在用户可见输出中:

Considered greeting in Chinese and offering assistance

这说明:

  • reasoning/thinking 内容被错误持久化
  • response schema 与插件实现不兼容
  • Agent 插件未正确处理新版 Responses API
  • conversation restore 阶段失败

为什么第一轮正常、第二轮崩

第一轮

通常只使用:

in-memory runtime state

不会读取历史持久化状态。


第二轮

会触发:

conversation deserialize
session restore
agent state replay

如果保存的 conversation object 非法:

  • reasoning item 类型不兼容
  • tool_call state 丢失
  • message schema 不匹配
  • output item 无法恢复

就会出现:

Error during execution

最终解决方案

删除以下目录后恢复正常:

1. workspaceStorage

%APPDATA%\Code\User\workspaceStorage

主要保存:

  • Workspace Chat Session
  • Agent Context
  • Tool State
  • MCP Session
  • Conversation Restore Data

这是最容易导致第二轮 execution fail 的目录。


2. globalStorage

%APPDATA%\Code\User\globalStorage

主要保存:

  • Extension Global State
  • Provider Cache
  • Auth Session
  • Model Metadata
  • Agent Registry

插件升级后 schema 不兼容时,这里也容易损坏。


为什么不用重装 VSCode

因为问题核心不在 VSCode 本体。

仅重装 VSCode:

不一定会删除 storage/cache

很多情况下问题依然存在。

真正需要清理的是:

Agent Session State
Conversation Cache
Extension Storage

后续建议

1. 不要同时安装多个 Agent

避免同时安装:

  • Continue
  • Cline
  • Roo
  • Copilot Chat
  • OpenAI Extension
  • Claude Dev
  • MCP Agent

多个 Chat Participant / Tool Provider 容易冲突。


2. 少使用 Nightly / Preview 版本

很多插件对:

  • GPT-5
  • Responses API
  • Reasoning Item
  • Tool Graph

兼容性仍不稳定。


3. 遇到类似问题优先清缓存

优先删除:

%APPDATA%\Code\User\workspaceStorage

必要时再删除:

%APPDATA%\Code\User\globalStorage

通常比重装 VSCode 更有效。


建议的排查顺序

Step 1

确认是否第二轮固定报错。


Step 2

检查是否出现 reasoning 泄漏:

Considered...
Thinking...
Reasoning...

Step 3

删除:

workspaceStorage

Step 4

如仍异常,再删除:

globalStorage

Step 5

最后才考虑:

  • 重装插件
  • 重装 VSCode
  • 重启系统

结论

本次问题本质是:

VSCode Agent Conversation State Corruption

属于 Agent / Responses API / Reasoning 持久化兼容问题。

通过清理:

workspaceStorage
globalStorage

即可恢复正常。

VSCode Agent 第二轮会话报错排查总结
https://bitdiary.cn/articles/vscode-agent-error
Author bitdiary
Published at 2026年5月26日