MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_prune_large_tool_outputs

Function test_prune_large_tool_outputs

core/src/compaction.rs:337–362  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

335
336 #[test]
337 fn test_prune_large_tool_outputs() {
338 // Create messages with large tool outputs that exceed protection threshold
339 let large_content = "x".repeat(200_000); // ~50k tokens
340 let large_content2 = "y".repeat(200_000); // ~50k tokens
341 let small_recent = "z".repeat(40_000); // ~10k tokens (recent, protected)
342
343 let messages = vec![
344 make_tool_result_msg("t1", &large_content), // old, should be pruned
345 make_text_msg("assistant", "processed t1"),
346 make_tool_result_msg("t2", &large_content2), // old, should be pruned
347 make_text_msg("assistant", "processed t2"),
348 make_tool_result_msg("t3", &small_recent), // recent, protected
349 make_text_msg("assistant", "done"),
350 ];
351
352 let result = prune_tool_outputs(&messages);
353 assert!(result.is_some());
354
355 let pruned = result.unwrap();
356 // t1 and/or t2 should be pruned (oldest first)
357 let t1_content = match &pruned[0].content[0] {
358 ContentBlock::ToolResult { content, .. } => content.as_text(),
359 _ => panic!("Expected ToolResult"),
360 };
361 assert_eq!(t1_content, PRUNED_MARKER);
362 }
363
364 #[test]
365 fn test_prune_preserves_recent_outputs() {

Callers

nothing calls this directly

Calls 2

prune_tool_outputsFunction · 0.85
as_textMethod · 0.80

Tested by

no test coverage detected