From 3c0d56d42477b6a4b51a77981e3a348e3024dd9a Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Sun, 31 May 2026 02:53:29 -0700 Subject: [PATCH] test(cache): cover medium tool result dedup (#2419) Harvested from #2393 with thanks to @wplll. Strengthens the tool-result dedup regression coverage by exercising repeated medium-sized outputs that are above the dedup threshold but below the truncation budget. --- crates/tui/src/client/chat.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/tui/src/client/chat.rs b/crates/tui/src/client/chat.rs index 9e87bb2e..39682cbe 100644 --- a/crates/tui/src/client/chat.rs +++ b/crates/tui/src/client/chat.rs @@ -2853,8 +2853,12 @@ mod stream_decoder_tests { } #[test] - fn request_builder_deduplicates_large_identical_tool_results_with_retrieval_hint() { + fn request_builder_deduplicates_medium_identical_tool_results_with_retrieval_hint() { with_tool_result_sha_spillover_root(|| { + // 2,000 chars is intentionally above TOOL_RESULT_DEDUP_MIN_CHARS + // (1,024) but below TOOL_RESULT_SENT_CHAR_BUDGET (12,000). This + // verifies the cache-saving path for repeated medium outputs that + // do not otherwise need truncation. let output = "A".repeat(2_000); let messages = vec![ tool_use_message("tool-1", "read_file", json!({"path": "README.md"})), @@ -2868,6 +2872,7 @@ mod stream_decoder_tests { let second = tool_message_content(&built, 1); assert_eq!(first, output); + assert!(!first.contains("[TOOL_RESULT_TRUNCATED]"), "got: {first}"); assert!( second.starts_with("