Skip to content

Commit 7044cdc

Browse files
authored
Persistant conv invariant (#1829)
* verifies conversation invariants on conversation deserialization * adds logic to check tool use history invariants * modifies history invariant function to take parameter to explicitly control range of history to examine * force updates conversation state on restart * removes extra update
1 parent bacd889 commit 7044cdc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/chat-cli/src/cli/chat/conversation_state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ impl ConversationState {
514514
.expect("unable to construct conversation state")
515515
}
516516

517-
pub async fn update_state(&mut self) {
518-
let needs_update = self.tool_manager.has_new_stuff.load(Ordering::Acquire);
517+
pub async fn update_state(&mut self, force_update: bool) {
518+
let needs_update = self.tool_manager.has_new_stuff.load(Ordering::Acquire) || force_update;
519519
if !needs_update {
520520
return;
521521
}

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ impl ChatContext {
558558
cs.reload_serialized_state(Arc::clone(&ctx), Some(output.clone())).await;
559559
input = Some(input.unwrap_or("In a few words, summarize our conversation so far.".to_owned()));
560560
cs.tool_manager = tool_manager;
561-
cs.enforce_tool_use_history_invariants(false);
561+
cs.update_state(true).await;
562562
cs
563563
} else {
564564
ConversationState::new(
@@ -812,7 +812,7 @@ impl ChatContext {
812812
debug!(?chat_state, "changing to state");
813813

814814
// Update conversation state with new tool information
815-
self.conversation_state.update_state().await;
815+
self.conversation_state.update_state(false).await;
816816

817817
let result = match chat_state {
818818
ChatState::PromptUser {

0 commit comments

Comments
 (0)