core-agent-ide/codex-rs/mcp-server/src
Owen Lin 8b7ec31ba7
feat(app-server): thread/rollback API (#8454)
Add `thread/rollback` to app-server to support IDEs undo-ing the last N
turns of a thread.

For context, an IDE partner will be supporting an "undo" capability
where the IDE (the app-server client) will be responsible for reverting
the local changes made during the last turn. To support this well, we
also need a way to drop the last turn (or more generally, the last N
turns) from the agent's context. This is what `thread/rollback` does.

**Core idea**: A Thread rollback is represented as a persisted event
message (EventMsg::ThreadRollback) in the rollout JSONL file, not by
rewriting history. On resume, both the model's context (core replay) and
the UI turn list (app-server v2's thread history builder) apply these
markers so the pruned history is consistent across live conversations
and `thread/resume`.

Implementation notes:
- Rollback only affects agent context and appends to the rollout file;
clients are responsible for reverting files on disk.
- If a thread rollback is currently in progress, subsequent
`thread/rollback` calls are rejected.
- Because we use `CodexConversation::submit` and codex core tracks
active turns, returning an error on concurrent rollbacks is communicated
via an `EventMsg::Error` with a new variant
`CodexErrorInfo::ThreadRollbackFailed`. app-server watches for that and
sends the BAD_REQUEST RPC response.

Tests cover thread rollbacks in both core and app-server, including when
`num_turns` > existing turns (which clears all turns).

**Note**: this explicitly does **not** behave like `/undo` which we just
removed from the CLI, which does the opposite of what `thread/rollback`
does. `/undo` reverts local changes via ghost commits/snapshots and does
not modify the agent's context / conversation history.
2026-01-06 21:23:48 +00:00
..
tool_handlers remove mcp-server/src/mcp_protocol.rs and the code that depends on it (#2360) 2025-08-18 00:29:18 -07:00
codex_tool_config.rs fix: update model examples to gpt-5.2 (#8566) 2026-01-06 08:47:29 -07:00
codex_tool_runner.rs feat(app-server): thread/rollback API (#8454) 2026-01-06 21:23:48 +00:00
error_code.rs fix: update OutgoingMessageSender::send_response() to take Serialize (#2263) 2025-08-13 14:29:13 -07:00
exec_approval.rs Removed experimental "command risk assessment" feature (#7799) 2025-12-10 09:48:11 -08:00
lib.rs chore: cleanup Config instantiation codepaths (#8226) 2025-12-17 18:01:17 -08:00
main.rs Added new auth-related methods and events to mcp server (#2496) 2025-08-20 20:36:34 -07:00
message_processor.rs [Auth] Choose which auth storage to use based on config (#5792) 2025-10-27 19:41:49 -07:00
outgoing_message.rs Reimplement skills loading using SkillsManager + skills/list op. (#7914) 2025-12-14 09:58:17 -08:00
patch_approval.rs chore: introduce ConversationManager as a clearinghouse for all conversations (#2240) 2025-08-13 13:38:18 -07:00