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

Function apply_magic_string_cache_control_triggers

src/proxy.rs:914–937  ·  view source on GitHub ↗
(body: &mut Value)

Source from the content-addressed store, hash-verified

912}
913
914fn apply_magic_string_cache_control_triggers(body: &mut Value) {
915 canonicalize_claude_body(body);
916 let Some(root) = body.as_object_mut() else {
917 return;
918 };
919 let existing_breakpoints = existing_cache_breakpoint_count(root);
920 let mut remaining_slots = 4usize.saturating_sub(existing_breakpoints);
921
922 if let Some(system) = root.get_mut("system") {
923 apply_magic_trigger_to_content(system, &mut remaining_slots);
924 }
925
926 if let Some(messages) = root.get_mut("messages").and_then(Value::as_array_mut) {
927 for message in messages {
928 let Some(message_map) = message.as_object_mut() else {
929 continue;
930 };
931 let Some(content) = message_map.get_mut("content") else {
932 continue;
933 };
934 apply_magic_trigger_to_content(content, &mut remaining_slots);
935 }
936 }
937}
938
939fn apply_magic_trigger_to_content(content: &mut Value, remaining_slots: &mut usize) {
940 match content {