feat(offscreen): read recent proposals into the brief; prompt follows up
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package offscreen
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -211,3 +212,37 @@ func TestDismissRecordsProposalDismissed(t *testing.T) {
|
||||
}
|
||||
_ = waitEvent(t, mem, "proposal_dismissed")
|
||||
}
|
||||
|
||||
func TestBriefIncludesRecentProposalsWithOutcome(t *testing.T) {
|
||||
mem := memory.NewFake()
|
||||
ctx := context.Background()
|
||||
// at = the test clock (Unix 1000); confirmed walk, dismissed stretch.
|
||||
_ = mem.Record(ctx, memory.Event{Kind: "proposal_made", At: time.Unix(1000, 0),
|
||||
Data: map[string]any{"proposal_id": "w", "next_action": "walk"}})
|
||||
_ = mem.Record(ctx, memory.Event{Kind: "action_taken", At: time.Unix(1000, 0),
|
||||
Data: map[string]any{"proposal_id": "w"}})
|
||||
_ = mem.Record(ctx, memory.Event{Kind: "proposal_made", At: time.Unix(1000, 0),
|
||||
Data: map[string]any{"proposal_id": "s", "next_action": "stretch"}})
|
||||
_ = mem.Record(ctx, memory.Event{Kind: "proposal_dismissed", At: time.Unix(1000, 0),
|
||||
Data: map[string]any{"proposal_id": "s"}})
|
||||
|
||||
m := newTestModeMem(t, &fakeTasks{}, okBackend(), mem)
|
||||
brief := m.assembleBrief()
|
||||
|
||||
if !strings.Contains(brief, "Recently proposed") {
|
||||
t.Fatalf("brief missing history section:\n%s", brief)
|
||||
}
|
||||
if !strings.Contains(brief, "walk") || !strings.Contains(brief, "confirmed") {
|
||||
t.Fatalf("brief missing confirmed walk:\n%s", brief)
|
||||
}
|
||||
if !strings.Contains(brief, "stretch") || !strings.Contains(brief, "dismissed") {
|
||||
t.Fatalf("brief missing dismissed stretch:\n%s", brief)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBriefOmitsHistoryWhenNoMemory(t *testing.T) {
|
||||
m := newTestMode(t, &fakeTasks{}, okBackend()) // no Memory injected
|
||||
if strings.Contains(m.assembleBrief(), "Recently proposed") {
|
||||
t.Fatal("history section should be absent without memory")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user