You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add functionality to summarize and clear conversation history
- Allow retrieval of the summary with /summary command
- Ensure the model acknowledges the summary in future responses
- Modify clear() method to optionally preserve summary
- Update UI messages for better user feedback
// Add summary if available - emphasize its importance more strongly
420
+
ifletSome(summary) = &self.latest_summary{
421
+
context_content.push_str("--- CRITICAL: PREVIOUS CONVERSATION SUMMARY - THIS IS YOUR PRIMARY CONTEXT ---\n");
422
+
context_content.push_str("This summary contains ALL relevant information from our previous conversation including tool uses, results, code analysis, and file operations. YOU MUST reference this information when answering questions and explicitly acknowledge specific details from the summary when they're relevant to the current question.\n\n");
423
+
context_content.push_str("SUMMARY CONTENT:\n");
424
+
context_content.push_str(summary);
425
+
context_content.push_str("\n--- END SUMMARY - YOU MUST USE THIS INFORMATION IN YOUR RESPONSES ---\n\n");
context_content.push_str("--- CONTEXT FILES END ---\n\n");
439
+
has_content = true;
410
440
}
411
-
context_content.push_str("--- CONTEXT FILES END ---\n\n");
412
-
413
-
let user_msg = UserInputMessage{
414
-
content:format!(
415
-
"Here is some information from my local q rules files, use these when answering questions:\n\n{}",
416
-
context_content
417
-
),
418
-
user_input_message_context:None,
419
-
user_intent:None,
420
-
};
421
-
let assistant_msg = AssistantResponseMessage{
422
-
message_id:None,
423
-
content:"I will use this when generating my response.".into(),
424
-
tool_uses:None,
425
-
};
426
-
Some((user_msg, assistant_msg))
427
-
}else{
428
-
None
429
-
}
430
-
},
431
-
Err(e) => {
432
-
warn!("Failed to get context files: {}", e);
433
-
None
434
-
},
441
+
},
442
+
Err(e) => {
443
+
warn!("Failed to get context files: {}", e);
444
+
},
445
+
}
446
+
}
447
+
448
+
if has_content {
449
+
let user_msg = UserInputMessage{
450
+
content:format!(
451
+
"Here is critical information you MUST consider when answering questions:\n\n{}",
452
+
context_content
453
+
),
454
+
user_input_message_context:None,
455
+
user_intent:None,
456
+
};
457
+
let assistant_msg = AssistantResponseMessage{
458
+
message_id:None,
459
+
content:"I will fully incorporate this information when generating my responses, and explicitly acknowledge relevant parts of the summary when answering questions.".into(),
460
+
tool_uses:None,
461
+
};
462
+
Some((user_msg, assistant_msg))
463
+
}else{
464
+
None
435
465
}
436
466
}
437
467
@@ -440,6 +470,67 @@ impl ConversationState {
440
470
self.context_message_length
441
471
}
442
472
473
+
/// Calculate the total character count in the conversation
474
+
pubfncalculate_char_count(&self) -> usize{
475
+
// Calculate total character count in all messages
0 commit comments