Files
DeepSeek-Reasonix/internal/runtime/agent/positional_compression_test.go
yhh 1b8b56aa65 feat(studio): compaction archives earlier turns to a file instead of summarizing; a skipped ask ends the turn as finished; chat overlays follow the design board
Compaction moves the folded span into <session>.outputs/fold-<hash>.md and leaves a pointer the model reads back with read_file. The summarizer path, its retries, bounds and tests are removed.

Answering an ask with no selection ends the turn normally instead of reporting a failure.

Find bar, overview and context cards, compact dialog, image preview, root-missing banner, toasts, side panel and prompt refine are aligned to the Chat-Tools board; the agent preset picker follows the Agent-Picker board.
2026-11-05 16:25:25 -08:00

58 lines
2.1 KiB
Go

package agent
import (
"context"
"reasonix/internal/state/sessionstore"
"reflect"
"strings"
"testing"
"reasonix/internal/contract/event"
"reasonix/internal/contract/provider"
"reasonix/internal/contract/tool"
)
func TestSummarizeAtProjectionBoundaryReportsFoldedAnchor(t *testing.T) {
sess := &sessionstore.Session{Messages: []provider.Message{
{Role: provider.RoleSystem, Content: "sys"},
{Role: provider.RoleUser, Content: "old boundary"},
{Role: provider.RoleAssistant, Content: strings.Repeat("old work ", 200)},
{Role: provider.RoleUser, Content: "retained boundary"},
{Role: provider.RoleAssistant, Content: "retained answer"},
}}
before := sess.Snapshot()
a := New(&fakeProvider{reply: "old work summarized"}, tool.NewRegistry(), sess, Options{}, event.Discard)
if err := a.SummarizeUpTo(context.Background(), 3); err != nil {
t.Fatalf("initial SummarizeUpTo: %v", err)
}
version := a.sess.win.compactionState.Projection.ProjectionVersion
err := a.SummarizeFrom(context.Background(), 1)
if err == nil || !strings.Contains(err.Error(), "no longer present in the model context") {
t.Fatalf("folded-boundary error = %v", err)
}
if a.sess.win.compactionState.Projection.ProjectionVersion != version {
t.Fatal("folded-boundary retry replaced the projection")
}
if !reflect.DeepEqual(sess.Snapshot(), before) {
t.Fatal("folded-boundary retry changed canonical history")
}
}
func TestSummarizeAtProjectionBoundaryReportsNoSavings(t *testing.T) {
sess := &sessionstore.Session{Messages: []provider.Message{
{Role: provider.RoleSystem, Content: "sys"},
{Role: provider.RoleUser, Content: "tiny"},
{Role: provider.RoleUser, Content: "keep boundary"},
}}
a := New(&fakeProvider{reply: strings.Repeat("long summary ", 30)}, tool.NewRegistry(), sess, Options{}, event.Discard)
err := a.SummarizeUpTo(context.Background(), 2)
if err == nil || !strings.Contains(err.Error(), "compressed context would not be smaller") {
t.Fatalf("no-savings error = %v", err)
}
if len(a.sess.win.compactionState.Projection.Messages) != 0 {
t.Fatal("no-savings positional compression installed a projection")
}
}