feat(automation): limit compact prompt history to recent messages

Modified compact_prompt_for_bot to only include the most recent N messages (messages_since_summary + 1) when building the compacted prompt string. This prevents excessive context from being included and improves performance by
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-11-11 15:30:52 -03:00
parent 979b205cdb
commit b021540c58

View file

@ -123,7 +123,11 @@ async fn compact_prompt_for_bot(
messages_since_summary
);
let mut compacted = String::new();
for (role, content) in &history {
let messages_to_include = history.iter()
.skip(history.len().saturating_sub(messages_since_summary ))
.take(messages_since_summary + 1);
for (role, content) in messages_to_include {
compacted.push_str(&format!("{}: {}\n", role, content));
}
let llm_provider = state.llm_provider.clone();