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
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package agent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"aego/editor/core/agentui"
|
|
)
|
|
|
|
func TestUsageEventUpdatesContextWindow(t *testing.T) {
|
|
p := &Panel{meter: agentui.NewMeter("guide", "tools")}
|
|
p.meterEvent(agentui.Event{Kind: agentui.EvUsage, Tokens: 250_000, Window: 400_000, Model: "large"})
|
|
l := p.contextLayout()
|
|
if l.Window != 400_000 || l.Used != 250_000 || l.Fraction() != 0.625 {
|
|
t.Fatalf("usage event lost the model window: %+v", l)
|
|
}
|
|
}
|
|
|
|
func TestCodexCompactionWithoutTokenCountPreservesTranscript(t *testing.T) {
|
|
h := newProviderTestHost()
|
|
p := providerPanel(t, h)
|
|
p.Submit("keep this task")
|
|
p.event(agentui.Event{Kind: agentui.EvText, Text: "work already done"})
|
|
p.event(agentui.Event{Kind: agentui.EvUsage, Tokens: 250_000, Window: 400_000})
|
|
p.event(agentui.Event{Kind: agentui.EvCompact})
|
|
if h.resets != 0 || len(p.blocks) != 3 || !strings.Contains(p.blocks[2].text, "compacted") || strings.Contains(p.blocks[2].text, "0 %") {
|
|
t.Fatalf("compaction reset the session or invented a percentage: %+v", p.blocks)
|
|
}
|
|
p.event(agentui.Event{Kind: agentui.EvUsage, Tokens: 80_000, Window: 400_000})
|
|
if l := p.contextLayout(); l.Used != 80_000 || l.Window != 400_000 {
|
|
t.Fatalf("post-compaction usage: %+v", l)
|
|
}
|
|
entries, err := agentui.Load(p.d.Root, p.log.ID)
|
|
if err != nil || len(entries) < 4 || entries[1].Text != "keep this task" || entries[2].Text != "work already done" {
|
|
t.Fatalf("transcript was lost during compaction: %+v, %v", entries, err)
|
|
}
|
|
}
|