MoonshotAI / MoonshotAI/kimi-code
/undo 后 TodoList 不回滚,仍显示被撤销回合写入的待办状态
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
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?
- 让 agent 做一个多步任务,期间它会调用
TodoList建立待办并逐步标记 done; - 该轮结束后执行
/undo(撤销这轮 prompt); - 观察 todo 面板:仍显示撤销前那轮写入的列表和 done 状态;
- 继续对话,模型仍引用旧的 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 时恢复。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Context.undo in packages/agent-core/src/agent/context/index.ts and trace TodoList state through packages/agent-core/src/tools/builtin/state/todo-list.ts, TodoListReminderInjector, and packages/agent-core/src/agent/records/index.ts. Reproduce the issue with the listed undo steps and compare live undo with session-record replay. Done means the TUI todo panel and injected todo state match the restored conversation state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100