generated from nhcarrigan/template
feat: Claude CLI 2.1.50–2.1.53 audit #171
@@ -2412,4 +2412,29 @@ mod tests {
|
||||
let content = serde_json::json!([]);
|
||||
assert_eq!(extract_tool_result_text(&content), None);
|
||||
}
|
||||
|
||||
// Verify the 50K tool result persistence threshold (CLI v2.1.51+).
|
||||
// Results > 50K chars are now persisted to disk; the stream may send null
|
||||
// or a large inline string. Both must be handled without panicking.
|
||||
#[test]
|
||||
fn test_extract_tool_result_text_large_content_above_50k_threshold() {
|
||||
let large_text = "x".repeat(60_000);
|
||||
let content = serde_json::Value::String(large_text.clone());
|
||||
assert_eq!(extract_tool_result_text(&content), Some(large_text));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tool_result_deserializes_with_null_content() {
|
||||
let json = r#"{"type":"tool_result","tool_use_id":"toolu_abc","content":null}"#;
|
||||
let block: ContentBlock = serde_json::from_str(json).unwrap();
|
||||
if let ContentBlock::ToolResult { tool_use_id, content, is_error } = block {
|
||||
assert_eq!(tool_use_id, "toolu_abc");
|
||||
assert!(content.is_null());
|
||||
assert_eq!(is_error, None);
|
||||
// Persisted-to-disk results produce null content → no preview shown
|
||||
assert_eq!(extract_tool_result_text(&content), None);
|
||||
} else {
|
||||
panic!("Expected ToolResult variant");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user