Skip to content

Conversation

@begelundmuller
Copy link
Contributor

@begelundmuller begelundmuller commented Dec 18, 2025

This PR adds two new APIs:

  • Adds an API SetConversationCheckpoint, which tracks a checkpoint in an AI session. This enables remembering at what point in a conversation the user last explicitly marked changes as accepted.
  • Adds an API RevertConversationWrites, which reverts any file writes/deletes made in a (subset) of an AI session. This enables reverting changes either for a specific write_file tool call, or for all write_file tool calls made since the latest checkpoint.

Internals:

  • Checkpoints are cheap to create – they just change a pointer to a message ID.
  • When a file is created/updated/deleted, the previous contents are stored in the write_file tool call's state, enabling easy reverts.
  • The full previous contents gets redacted before any LLM call so it doesn't pollute the context and use unnecessary tokens.

Remaining tasks (can be done in follow ups):

  • To prevent unbounded data growth, remove file contents snapshots when a checkpoint is created or after 24 hours.

Here's the full request parameters and response payload:

// Request message for RuntimeService.SetConversationCheckpoint
message SetConversationCheckpointRequest {
  // Instance the conversation belongs to.
  string instance_id = 1 [(validate.rules).string = {pattern: "^[_\\-a-zA-Z0-9]+$"}];
  // Conversation ID to checkpoint.
  string conversation_id = 2;
  // Message ID of the latest message *before* the checkpoint.
  string message_id = 3;
}

// Response message for RuntimeService.SetConversationCheckpoint
message SetConversationCheckpointResponse {}

// Request message for RuntimeService.RevertConversationWrites
message RevertConversationWritesRequest {
  // Instance the conversation belongs to.
  string instance_id = 1 [(validate.rules).string = {pattern: "^[_\\-a-zA-Z0-9]+$"}];
  // Conversation ID to revert writes for.
  string conversation_id = 2;
  // Start message ID to revert from (inclusive). If empty, it reverts from after the conversation's checkpoint.
  string from_message_id = 3;
  // End message ID to revert to (inclusive). If empty, it reverts to the latest message.
  string to_message_id = 4;
}

// Response message for RuntimeService.RevertConversationWrites
message RevertConversationWritesResponse {
  repeated string restored_paths = 1;
}

Closes https://linear.app/rilldata/issue/PLAT-358/checkpointingreverting-ai-writes

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@begelundmuller begelundmuller self-assigned this Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants