TestPackKeepsPairedToolMessage: a healthy assistant+tool pair that fits the budget stays intact: don't regress into dropping good pairs.
(t *testing.T)
| 174 | // TestPackKeepsPairedToolMessage: a healthy assistant+tool pair that fits the |
| 175 | // budget stays intact: don't regress into dropping good pairs. |
| 176 | func TestPackKeepsPairedToolMessage(t *testing.T) { |
| 177 | history := []Message{ |
| 178 | {Role: RoleAssistant, ToolCalls: []ToolCall{{ID: "c1", Name: "bash"}}}, |
| 179 | {Role: RoleTool, ToolCallID: "c1", Content: "ok"}, |
| 180 | {Role: RoleAssistant, Content: "done"}, |
| 181 | } |
| 182 | r := Pack(history, 10000) |
| 183 | if len(r.Messages) != 3 { |
| 184 | t.Fatalf("all 3 messages should be kept, got %d: %+v", len(r.Messages), r.Messages) |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | // TestPackKeepsNewestToolPairOverBudget: when the newest message is a tool |
| 189 | // result and its owning assistant won't fit the budget, Pack must keep the pair |