MCPcopy Create free account
hub / github.com/LeenHawk/sgproxy / existing_cache_breakpoint_count

Function existing_cache_breakpoint_count

src/proxy.rs:1006–1027  ·  view source on GitHub ↗
(root: &serde_json::Map<String, Value>)

Source from the content-addressed store, hash-verified

1004}
1005
1006fn existing_cache_breakpoint_count(root: &serde_json::Map<String, Value>) -> usize {
1007 let mut count = 0;
1008
1009 if root.contains_key("cache_control") {
1010 count += 1;
1011 }
1012
1013 if let Some(system) = root.get("system") {
1014 count += count_cache_controls_in_content(system);
1015 }
1016
1017 if let Some(messages) = root.get("messages").and_then(Value::as_array) {
1018 for message in messages {
1019 let Some(content) = message.as_object().and_then(|item| item.get("content")) else {
1020 continue;
1021 };
1022 count += count_cache_controls_in_content(content);
1023 }
1024 }
1025
1026 count
1027}
1028
1029fn count_cache_controls_in_content(content: &Value) -> usize {
1030 match content {

Calls 1

Tested by

no test coverage detected