| 155 | } |
| 156 | |
| 157 | func CountClearedToolResult(messages []map[string]any) int { |
| 158 | count := 0 |
| 159 | for _, msg := range messages { |
| 160 | content, ok := contentBlocks(msg["content"]) |
| 161 | if !ok { |
| 162 | continue |
| 163 | } |
| 164 | for _, item := range content { |
| 165 | itemContent, ok := item["content"].(string) |
| 166 | if !ok { |
| 167 | continue |
| 168 | } |
| 169 | itemType := getValueFrom(item, "type") |
| 170 | if itemType == "tool_result" && itemContent == cleanPlaceHolder { |
| 171 | count++ |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | return count |
| 176 | } |
| 177 | |
| 178 | func MicroCompactResult(content string, maxCharsOpt ...int) string { |
| 179 | maxChars := defaultMaxResultChars |