The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Keep the tail of long traces in the learning projection
vetlucasmartins2791dcd4d1ea
diff --git a/cli/beacon/internal/learning/evaluator.go b/cli/beacon/internal/learning/evaluator.goindex 1241e3c0..dc517d0d 100644--- a/cli/beacon/internal/learning/evaluator.go+++ b/cli/beacon/internal/learning/evaluator.go@@ -189,7 +189,19 @@ func BuildProjection(show asymptoteobserve.TraceShowResultV1) Projection {}events := show.Eventsif len(events) > maxProjectionEvents {- events = events[:maxProjectionEvents]+ // Long sessions resolve at the end: keep the opening context and the tail+ // instead of only the first maxProjectionEvents events, otherwise the+ // evaluator never sees the fix or outcome a reusable lesson depends on.+ head := maxProjectionEvents / 2+ tail := maxProjectionEvents - head+ combined := make([]asymptoteobserve.TraceEventV1, 0, maxProjectionEvents+1)+ combined = append(combined, events[:head]...)+ combined = append(combined, asymptoteobserve.TraceEventV1{+ Type: "omitted",+ Summary: fmt.Sprintf("%d events omitted from the middle of this trace", len(events)-maxProjectionEvents),+ })+ combined = append(combined, events[len(events)-tail:]...)+ events = combined}for _, event := range events {projected := ProjectedEvent{diff --git a/cli/beacon/internal/learning/evaluator_test.go b/cli/beacon/internal/learning/evaluator_test.goindex 43c7b663..7314380e 100644--- a/cli/beacon/internal/learning/evaluator_test.go+++ b/cli/beacon/internal/learning/evaluator_test.go@@ -2,6 +2,7 @@ package learningimport ("encoding/json"+ "fmt""net/http""net/http/httptest""strings"@@ -93,6 +94,30 @@ func TestProjectionRedactsAndBoundsContent(t *testing.T) {}}+func TestProjectionKeepsHeadAndTailOfLongTraces(t *testing.T) {+ show := testTraceShow()+ show.Events = nil+ total := maxProjectionEvents * 3+ for i := 1; i <= total; i++ {+ show.Events = append(show.Events, asymptoteobserve.TraceEventV1{+ Number: i,+ Type: "tool",+ Action: "tool.invoked",+ Summary: fmt.Sprintf("event %d", i),+ })+ }+ projection := BuildProjection(show)+ if len(projection.Events) != maxProjectionEvents+1 {+ t.Fatalf("projected events = %d, want %d", len(projection.Events), maxProjectionEvents+1)+ }+ if first := projection.Events[0].Summary; first != "event 1" {+ t.Fatalf("head dropped: first = %q", first)+ }+ if last := projection.Events[len(projection.Events)-1].Summary; last != fmt.Sprintf("event %d", total) {+ t.Fatalf("tail dropped: last = %q", last)+ }+}+func TestEvaluateRequiresAnswersOutsideDryRun(t *testing.T) {server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {_, _ = w.Write([]byte(`{"answers":{}}`))