bug: 编辑器撤销写入失败后丢失历史,无法重试
Author: 2gg-bitCreated Sep 27, 2026Updated Sep 27, 2026
复现
使用 StrReplaceEditor.execute(command="str_replace", ...) 修改文件后,如果 undo_edit 的文件写入因临时 I/O 错误失败,再次调用 undo_edit 会得到 No edit history found,无法重试恢复原内容。
原因:undo_edit 在 await operator.write_file(...) 成功前已经对 _file_history[path] 调用 pop()。本地文件和 sandbox 操作器均可能写入失败。
预期:失败的撤销保留历史;成功写回文件后才消费历史记录。
已在 main 上用临时文件、真实编辑流程以及模拟写入失败复现:重试撤销的回归测试失败,正常多次撤销测试通过。准备提交最小修复及这两项测试。
AI 披露:本问题由 OpenAI Codex AI 分析并使用本地测试验证,尚未经人工审阅。
Source: FoundationAgents/OpenManus