Files
aego/editor/panels/agent/repeated_runs_test.go
sanspie a6822156cd
ci-platforms / windows amd64 smoke (push) Skipped
ci / release (push) Successful in 8m58s
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci / checks (push) Successful in 4m46s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 13m28s
Finish Stage 12 editor fixes and refreshed platformer
2026-11-05 17:36:42 +03:00

53 lines
1.7 KiB
Go

package agent
import (
"fmt"
"testing"
"aego/editor/core/agentui"
)
func TestRepeatedFailedRunsGroupWithoutLosingTranscript(t *testing.T) {
h := newProviderTestHost()
p := providerPanel(t, h)
p.Submit("run the scene")
for i := range 3 {
id := fmt.Sprint(i)
p.event(agentui.Event{Kind: agentui.EvToolStart, Tool: "scene_run", CallID: id, Args: `{"file":"main.aescene"}`})
p.event(agentui.Event{Kind: agentui.EvToolResult, Tool: "scene_run", CallID: id, Result: "same failure", Failed: true})
}
if len(p.blocks) != 2 || p.blocks[1].kind != blockFailed || p.blocks[1].repeats != 3 {
t.Fatalf("identical failures were not grouped: %+v", p.blocks)
}
entries, err := agentui.Load(p.d.Root, p.log.ID)
if err != nil {
t.Fatal(err)
}
results := 0
for _, e := range entries {
if e.Kind == "result" && e.Tool == "scene_run" {
results++
}
}
if results != 3 {
t.Fatalf("transcript kept %d of 3 results", results)
}
old := p.blocksFrom(entries)
if len(old) != 2 || old[1].repeats != 3 {
t.Fatalf("reopened transcript lost the group: %+v", old)
}
// Different output, different arguments and other tools are never hidden.
for i, tc := range []struct{ tool, args, result string }{
{"scene_run", `{"file":"main.aescene"}`, "different failure"},
{"scene_run", `{"file":"other.aescene"}`, "different failure"},
{"scene_validate", `{"file":"other.aescene"}`, "different failure"},
} {
id := fmt.Sprintf("different-%d", i)
p.event(agentui.Event{Kind: agentui.EvToolStart, Tool: tc.tool, CallID: id, Args: tc.args})
p.event(agentui.Event{Kind: agentui.EvToolResult, Tool: tc.tool, CallID: id, Result: tc.result, Failed: true})
}
if len(p.blocks) != 5 {
t.Fatalf("different failures were hidden: %+v", p.blocks)
}
}