(visibleToolResultIDs map[string]struct{})
| 1164 | newBlocks := append([]map[string]any{}, blocks...) |
| 1165 | last := copyMap(newBlocks[len(newBlocks)-1]) |
| 1166 | last["cache_control"] = map[string]any{"type": "ephemeral"} |
| 1167 | newBlocks[len(newBlocks)-1] = last |
| 1168 | cp := copyMap(msg) |
| 1169 | cp["content"] = newBlocks |
| 1170 | result = append(result, cp) |
| 1171 | } |
| 1172 | return result |
| 1173 | } |
| 1174 | |
| 1175 | func absInt(value int) int { |
| 1176 | if value < 0 { |
| 1177 | return -value |
| 1178 | } |
| 1179 | return value |
| 1180 | } |
| 1181 | |
| 1182 | func VisibleToolResultIDs(messages []map[string]any) map[string]struct{} { |
| 1183 | ids := map[string]struct{}{} |
| 1184 | for _, message := range messages { |
| 1185 | blocks := contentBlocks(message["content"]) |
| 1186 | for _, block := range blocks { |
| 1187 | if block["type"] != "tool_result" { |
| 1188 | continue |
no test coverage detected