Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix: return all events as context in ReadTokenEventsAppendOrder

Cursor Agentfadc77bda0b3
diff --git a/cli/beacon/internal/endpoint/dashboard/events.go b/cli/beacon/internal/endpoint/dashboard/events.go
index 3f0ab6eb..dd71b5c2 100644
--- a/cli/beacon/internal/endpoint/dashboard/events.go
+++ b/cli/beacon/internal/endpoint/dashboard/events.go
@@ -116,10 +116,11 @@ func ReadEventsAppendOrder(path string, query EventQuery) ([]schema.Event, error
return events, nil
}
-// ReadTokenEventsAppendOrder returns query-matched events plus every
-// session.context event in one pass over the log. Session context is kept
-// separate so token totals and TotalEvents still describe only the requested
-// time/model/session slice while user attribution can reach back to SessionStart.
+// ReadTokenEventsAppendOrder returns query-matched events plus the unfiltered
+// event set in one pass over the log. The unfiltered set lets aggregate resolve
+// session-level context — user attribution from SessionStart and the live capture
+// start times liveCaptureStarts needs to place the live/poll cutover — even when
+// the report is narrowed by time, model, or session.
func ReadTokenEventsAppendOrder(path string, query EventQuery) ([]schema.Event, []schema.Event, error) {
result, err := ReadEvents(path, EventQuery{NoLimit: true})
if err != nil {
@@ -127,11 +128,9 @@ func ReadTokenEventsAppendOrder(path string, query EventQuery) ([]schema.Event,
}
SortRecordsAppendOrder(result.Events)
events := make([]schema.Event, 0, len(result.Events))
- contexts := make([]schema.Event, 0)
+ contexts := make([]schema.Event, 0, len(result.Events))
for _, record := range result.Events {
- if record.Event.Event.Action == "session.context" {
- contexts = append(contexts, record.Event)
- }
+ contexts = append(contexts, record.Event)
if matchesQuery(record, query) {
events = append(events, record.Event)
}