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.
This commit is contained in:
@@ -2853,8 +2853,12 @@ mod stream_decoder_tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[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(|| {
|
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 output = "A".repeat(2_000);
|
||||||
let messages = vec![
|
let messages = vec![
|
||||||
tool_use_message("tool-1", "read_file", json!({"path": "README.md"})),
|
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);
|
let second = tool_message_content(&built, 1);
|
||||||
|
|
||||||
assert_eq!(first, output);
|
assert_eq!(first, output);
|
||||||
|
assert!(!first.contains("[TOOL_RESULT_TRUNCATED]"), "got: {first}");
|
||||||
assert!(
|
assert!(
|
||||||
second.starts_with("<TOOL_RESULT_REF sha=\""),
|
second.starts_with("<TOOL_RESULT_REF sha=\""),
|
||||||
"got: {second}"
|
"got: {second}"
|
||||||
|
|||||||
Reference in New Issue
Block a user