require.Equal(t, 1, server.Calls())
body := server.Call(0).body
- require.Equal(t, prompt("Ada"), body["instructions"])
+ require.Equal(t, prompt("Ada", ""), body["instructions"])
require.Equal(t, "gpt-test", body["model"])
require.Equal(t, map[string]any{"effort": "high"}, body["reasoning"])
require.Equal(t, "agent-key", body["prompt_cache_key"])
writeEvents(w, completedEvent([]any{messageItem(long[call.number])}, 100, 0, 5))
}
- line, err := newTestCompactor(t, server).Summarize(t.Context(), leafTask())
+ compactor := newTestCompactor(t, server)
+ line, err := compactor.Summarize(t.Context(), leafTask())
require.NoError(t, err)
require.Equal(t, long[2], line)
require.Equal(t, 3, server.Calls())
+ records := readUsage(t, compactor.client.usage.path)
+ require.Len(t, records, 3)
+ for n, record := range records {
+ require.Equal(t, &[2]int{0, 0}, record.Node)
+ require.Equal(t, len(long[n]), record.TextBytes)
+ }
+
first := inputParts(t, server.Call(0))
require.Len(t, first, 2)
for n, want := range []string{long[0], long[1]} {
require.Equal(t, first, parts[:2])
require.Equal(t, []string{tooLong(want)}, parts[2:])
require.Contains(t, parts[2], "was "+strconv.Itoa(len(want))+" bytes,")
- require.Contains(t, parts[2], "\n"+want[:512]+"| ← LIMIT")
+ require.Contains(t, parts[2], "\n"+want[:512]+"| <- LIMIT")
note, err := json.Marshal(map[string]string{
"type": "input_text",
client := newClient(server.URL, apiKey(testKey), "agent-key", filepath.Join(t.TempDir(), "usage.jsonl"))
- return newCompactor(client, "Ada", ModelConfig{
+ return newCompactor(client, adaPrompt, ModelConfig{
Model: "gpt-test",
Effort: "high",
})
}
+// adaPrompt returns the prompt of the agent Ada, without instructions.
+func adaPrompt() (string, error) {
+ return prompt("Ada", ""), nil
+}
+
func leafTask() Task {
return Task{
Level: 0,