Skip to content
Open
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ignore = "0.4"
rand = "0.9"
iana-time-zone = "0.1"
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp"] }
libc = "0.2"
ratatui = { version = "0.30", default-features = false, features = ["crossterm_0_29"] }
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] }
regex = "1"
Expand Down
1 change: 1 addition & 0 deletions crates/browser-use-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ rand.workspace = true
regex.workspace = true
reqwest = { workspace = true, features = ["stream"] }
rustls.workspace = true
libc.workspace = true
serde.workspace = true
serde_json.workspace = true
sha2.workspace = true
Expand Down
11 changes: 10 additions & 1 deletion crates/browser-use-agent/src/compact/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,16 @@ pub fn compacted_history_from_summary(
summary_suffix: CompactionSummary,
token_limit: usize,
) -> CompactedHistory {
let summary_text = format!("{SUMMARY_PREFIX}\n{}", summary_suffix.text);
// Apply the empty-summary fallback to the SUFFIX before prepending the
// prefix — otherwise the prefix makes the string non-empty and the fallback
// in build_compacted_history is dead code, shipping PREFIX + "" (total
// post-compaction amnesia; real_v8 task 24).
let suffix_text = if summary_suffix.text.trim().is_empty() {
"(no summary available)".to_string()
} else {
summary_suffix.text.clone()
};
let summary_text = format!("{SUMMARY_PREFIX}\n{suffix_text}");
let user_messages: Vec<String> = history.iter().filter_map(real_user_message_text).collect();
let items = build_compacted_history(&user_messages, &summary_text, token_limit);

Expand Down
7 changes: 5 additions & 2 deletions crates/browser-use-agent/src/compact/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ async fn context_window_exceeded_with_only_prompt_left_propagates() {
}

#[tokio::test]
async fn empty_model_summary_yields_prefix_only_summary() {
async fn empty_model_summary_yields_no_summary_available_fallback() {
// The model returns an empty summary => summary_text = PREFIX + "\n" + "".
// (The "(no summary available)" placeholder only applies when the WHOLE
// summary_text is empty, which it never is here because the prefix is present;
Expand All @@ -390,7 +390,10 @@ async fn empty_model_summary_yields_prefix_only_summary() {

let last = item_text(compacted.items.last().unwrap());
assert_eq!(last, compacted.summary_text);
assert_eq!(compacted.summary_text, format!("{SUMMARY_PREFIX}\n"));
assert_eq!(
compacted.summary_text,
format!("{SUMMARY_PREFIX}\n(no summary available)")
);
}

// ---- (5) end-to-end through the real TurnLoop -----------------------------
Expand Down
Loading
Loading