Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions crates/goose/src/agents/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,13 @@ impl Agent {
.ok_or_else(|| anyhow::anyhow!("Session {} has no conversation", session_config.id))?;

let needs_auto_compact = !is_manual_compact
&& crate::context_mgmt::check_if_compaction_needed(self, &conversation, None, &session)
.await?;
&& crate::context_mgmt::check_if_compaction_needed(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any particular reason to not have these imported with a use crate::context_mgmt::{...}?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

self.provider().await?.as_ref(),
&conversation,
None,
&session,
)
.await?;

let conversation_to_compact = conversation.clone();

Expand Down Expand Up @@ -817,7 +822,7 @@ impl Agent {
)
);

match crate::context_mgmt::compact_messages(self, &conversation_to_compact, false).await {
match crate::context_mgmt::compact_messages(self.provider().await?.as_ref(), &conversation_to_compact, is_manual_compact).await {

Copilot AI Nov 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third parameter should be false not is_manual_compact. This is for auto-compaction (needs_auto_compact path) and should preserve the user message. Using is_manual_compact here will incorrectly preserve messages during manual compacts when this branch shouldn't even execute.

Suggested change
match crate::context_mgmt::compact_messages(self.provider().await?.as_ref(), &conversation_to_compact, is_manual_compact).await {
match crate::context_mgmt::compact_messages(self.provider().await?.as_ref(), &conversation_to_compact, false).await {

Copilot uses AI. Check for mistakes.
Ok((compacted_conversation, summarization_usage)) => {
SessionManager::replace_conversation(&session_config.id, &compacted_conversation).await?;
Self::update_session_metrics(&session_config, &summarization_usage, true).await?;
Expand Down Expand Up @@ -1138,7 +1143,7 @@ impl Agent {
)
);

match crate::context_mgmt::compact_messages(self, &conversation, true).await {
match crate::context_mgmt::compact_messages(self.provider().await?.as_ref(), &conversation, true).await {
Comment thread
katzdave marked this conversation as resolved.
Outdated
Ok((compacted_conversation, usage)) => {
SessionManager::replace_conversation(&session_config.id, &compacted_conversation).await?;
Self::update_session_metrics(&session_config, &usage, true).await?;
Expand Down
Loading