Skip to content

/undo 后 TodoList 不回滚,仍显示被撤销回合写入的待办状态 #3058

Open

Description

@dhnihaoya

What version of Kimi Code is running?

0.36.0

Which open platform/subscription were you using?

Kimi 订阅(managed:moonshot-cn,kimi-for-coding)

Which model were you using?

kimi-for-coding

What platform is your computer?

Darwin 25.4.0 arm64 arm

What issue are you seeing?

执行 /undo 撤销上一轮对话后,TodoList 不会随之回滚:

  • 被撤销的那一轮里 agent 通过 TodoList 工具写入/更新的待办(例如把若干条标成 done,或整表新建)在撤销后原样保留;
  • TUI 的 todo 面板继续显示撤销前的状态;
  • 继续对话时,模型通过 todo 注入看到的也是这份过期状态,会基于"已经完成/已存在"的错误待办继续工作,和实际回滚后的上下文对不上。

What steps can reproduce the bug?

  1. 让 agent 做一个多步任务,期间它会调用 TodoList 建立待办并逐步标记 done;
  2. 该轮结束后执行 /undo(撤销这轮 prompt);
  3. 观察 todo 面板:仍显示撤销前那轮写入的列表和 done 状态;
  4. 继续对话,模型仍引用旧的 todo 状态。

What is the expected behavior?

/undo 回滚对话的同时,todo 列表应恢复到被恢复到的对话点对应的状态(或至少清空/重新同步),保证 TUI 展示和注入给模型的状态与当前上下文一致。

Additional information

看了下源码(当前 main),怀疑根因是 undo 路径完全没有触及 todo 的存储:

  • todo 存在 agent 级 tool store(packages/agent-core/src/tools/builtin/state/todo-list.ts,TODO_STORE_KEY = 'todo'),写入走 updateStore;
  • Context.undo(packages/agent-core/src/agent/context/index.ts)只回滚 context 消息、通知 injector、清空 open steps / pending tool results,从不回滚 tool store;
  • tools.update_store 记录只在整段 record 重放(恢复会话)时才会重放(packages/agent-core/src/agent/records/index.ts),live undo 不走这条路;
  • 结果是 TodoListReminderInjector(packages/agent-core/src/agent/injection/todo-list.ts)和 TUI 读到的都是过期状态。

一个可能的方向:undo 时按剩余记录重放 tools.update_store,或为 store 写入记录 checkpoint 并在 undo 时恢复。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions