-
Notifications
You must be signed in to change notification settings - Fork 396
feat: Adds checkpointing functionality using Git CLI commands #2896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
39ade9d
c5c033f
1760839
5a27533
643912d
7f0cba9
30b5a95
8eb341a
566f0c9
e38c1f8
eae59d5
bc23993
b709854
a97f3f8
25645b1
0f74051
a9801c0
13a1385
e1a3cfe
a44f814
3829fa2
0a6e993
58ea878
f1b76f8
e2c3590
f1f0816
1c366e4
594305b
e9f30d9
9211e75
e16541e
049ea08
e479178
3601482
163ed21
a313dfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,10 @@ use crate::cli::agent::hook::{ | |
| HookTrigger, | ||
| }; | ||
| use crate::cli::chat::ChatError; | ||
| use crate::cli::chat::checkpoint::{ | ||
| Checkpoint, | ||
| CheckpointManager, | ||
| }; | ||
| use crate::cli::chat::cli::model::{ | ||
| ModelInfo, | ||
| get_model_info, | ||
|
|
@@ -138,6 +142,8 @@ pub struct ConversationState { | |
| /// Maps from a file path to [FileLineTracker] | ||
| #[serde(default)] | ||
| pub file_line_tracker: HashMap<String, FileLineTracker>, | ||
|
|
||
| pub checkpoint_manager: Option<CheckpointManager>, | ||
| #[serde(default = "default_true")] | ||
| pub mcp_enabled: bool, | ||
| /// Tangent mode checkpoint - stores main conversation when in tangent mode | ||
|
|
@@ -203,6 +209,7 @@ impl ConversationState { | |
| model: None, | ||
| model_info: model, | ||
| file_line_tracker: HashMap::new(), | ||
| checkpoint_manager: None, | ||
| mcp_enabled, | ||
| tangent_state: None, | ||
| } | ||
|
|
@@ -891,6 +898,20 @@ Return only the JSON configuration, no additional text.", | |
| self.transcript.push_back(message); | ||
| } | ||
|
|
||
| /// Restore conversation from a checkpoint's history snapshot | ||
| pub fn restore_to_checkpoint(&mut self, checkpoint: &Checkpoint) -> Result<(), eyre::Report> { | ||
| // 1. Restore history from snapshot | ||
| self.history = checkpoint.history_snapshot.clone(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious? Can a checkpoint corrupt conversation history by any means? Like a tool use without tool results and so on?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The checkpoint is created after the tool executes successfully and in handle_response, so that should be fine. Thanks for the callout — we can test it more thoroughly during the bug bash |
||
|
|
||
| // 2. Clear any pending next message (uncommitted state) | ||
| self.next_message = None; | ||
|
|
||
| // 3. Update valid history range | ||
| self.valid_history_range = (0, self.history.len()); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| /// Swapping agent involves the following: | ||
| /// - Reinstantiate the context manager | ||
| /// - Swap agent on tool manager | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.