Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: always send MessagesUpdated from run_turn_cycle so the TUI history includes tool call/result messages

tikikuneb27734a808c
diff --git a/src-tauri/src/core/agent/loop.rs b/src-tauri/src/core/agent/loop.rs
index c497a776f..a10700724 100644
--- a/src-tauri/src/core/agent/loop.rs
+++ b/src-tauri/src/core/agent/loop.rs
@@ -1005,10 +1005,7 @@ async fn run_turn_cycle(
// mid-task by a fixed turn cap.
let unlimited = max_turns == 0;
let mut turn: usize = 0;
- // Set on any turn where compaction ran, so the final return can emit
- // `MessagesUpdated` even when compaction happened on a prior (tool-call)
- // turn and the final turn itself didn't need retry.
- let mut did_compact = false;
+
while unlimited || turn < max_turns {
let _ = events.send(StreamEvent::Step {
index: (turn as u32) + 1,
@@ -1047,7 +1044,6 @@ async fn run_turn_cycle(
attempts + 1
);
conversation_messages = compacted;
- did_compact = true;
keep_recent = (keep_recent / 2).max(2);
attempts += 1;
}
@@ -1061,11 +1057,9 @@ async fn run_turn_cycle(
let tool_calls = extract_tool_calls(&completion);
if tool_calls.is_empty() {
- if did_compact {
- let _ = events.send(StreamEvent::MessagesUpdated {
- messages: conversation_messages.clone(),
- });
- }
+ let _ = events.send(StreamEvent::MessagesUpdated {
+ messages: conversation_messages.clone(),
+ });
return Ok(completion);
}