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

Function test_prune_preserves_recent_outputs

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

Source from the content-addressed store, hash-verified

363
364 #[test]
365 fn test_prune_preserves_recent_outputs() {
366 // Recent output alone fills the protection budget (~50k tokens)
367 let large_old = "a".repeat(400_000); // ~100k tokens
368 let recent = "b".repeat(200_000); // ~50k tokens (fills protection budget)
369
370 let messages = vec![
371 make_tool_result_msg("old", &large_old),
372 make_text_msg("assistant", "ok"),
373 make_tool_result_msg("recent", &recent),
374 make_text_msg("assistant", "done"),
375 ];
376
377 let result = prune_tool_outputs(&messages);
378 assert!(result.is_some());
379
380 let pruned = result.unwrap();
381 // Old should be pruned
382 let old_content = match &pruned[0].content[0] {
383 ContentBlock::ToolResult { content, .. } => content.as_text(),
384 _ => panic!("Expected ToolResult"),
385 };
386 assert_eq!(old_content, PRUNED_MARKER);
387
388 // Recent should be preserved
389 let recent_content = match &pruned[2].content[0] {
390 ContentBlock::ToolResult { content, .. } => content.as_text(),
391 _ => panic!("Expected ToolResult"),
392 };
393 assert_ne!(recent_content, PRUNED_MARKER);
394 }
395
396 #[test]
397 fn test_prune_marker_text() {

Callers

nothing calls this directly

Calls 2

prune_tool_outputsFunction · 0.85
as_textMethod · 0.80

Tested by

no test coverage detected