(projections []ProjectedExchange)
| 130 | } |
| 131 | |
| 132 | func buildProjectionText(projections []ProjectedExchange) string { |
| 133 | lines := []string{"[Earlier conversation — summarized]\n"} |
| 134 | for i, proj := range projections { |
| 135 | parts := []string{fmt.Sprintf("Turn %d", i+1)} |
| 136 | if proj.Summary != "" { |
| 137 | parts = append(parts, fmt.Sprintf(" Summary: %s", proj.Summary)) |
| 138 | } |
| 139 | if len(proj.ToolCalls) > 0 { |
| 140 | parts = append(parts, fmt.Sprintf(" Tools called: %s", strings.Join(proj.ToolCalls, ", "))) |
| 141 | } |
| 142 | if len(proj.KeyOutputs) > 0 { |
| 143 | outputs := strings.Join(proj.KeyOutputs[:MinInt(3, len(proj.KeyOutputs))], "; ") |
| 144 | parts = append(parts, fmt.Sprintf(" Key outputs: %s", outputs)) |
| 145 | } |
| 146 | lines = append(lines, strings.Join(parts, " ")) |
| 147 | } |
| 148 | return strings.Join(lines, "\n") |
| 149 | } |
| 150 | |
| 151 | func CollapseMessages(messages []map[string]any, keepRecent int) []map[string]any { |
| 152 | if len(messages) == 0 { |
no test coverage detected