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:
parent
979b205cdb
commit
b021540c58
1 changed files with 5 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue