attempted fix of lag

This commit is contained in:
Ryan Ward
2026-08-20 08:52:36 -05:00
parent 87080c8086
commit 32d969ea4f
5 changed files with 100 additions and 0 deletions
+11
View File
@@ -793,6 +793,11 @@ impl AIConversation {
) {
use crate::ai::bedrock::convert::{ContentPart, MessageContent};
// Cap the archive to prevent unbounded growth. The archive is only used by
// `recall_tool_history` which already truncates individual results to 50K chars,
// so retaining the most recent entries is sufficient for lookup.
const MAX_TOOL_RESULT_ARCHIVE_ENTRIES: usize = 400;
let mut pending_tool_uses: Vec<crate::ai::bedrock::convert::ConversationMessage> =
Vec::new();
@@ -831,6 +836,12 @@ impl AIConversation {
for tool_use in pending_tool_uses {
self.tool_result_archive.push(tool_use);
}
// Evict oldest entries if the archive exceeds the cap.
if self.tool_result_archive.len() > MAX_TOOL_RESULT_ARCHIVE_ENTRIES {
let excess = self.tool_result_archive.len() - MAX_TOOL_RESULT_ARCHIVE_ENTRIES;
self.tool_result_archive.drain(0..excess);
}
}
pub fn append_to_bedrock_history(