Skip to content

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

Keep Beacon's own session records out of session recency

Claude087c49b218ac
diff --git a/cli/beacon/internal/handoff/runtimelog.go b/cli/beacon/internal/handoff/runtimelog.go
index ecbe853a..a5768ebb 100644
--- a/cli/beacon/internal/handoff/runtimelog.go
+++ b/cli/beacon/internal/handoff/runtimelog.go
@@ -87,6 +87,13 @@ func logSessionForPrefix(logPath, prefix, harness string) (string, error) {
return "", &AmbiguousError{ID: prefix, Candidates: candidates}
}
+// beaconBookkeeping reports whether action is a record Beacon writes into a session's timeline
+// after the fact (sharing it, linking it to a commit). Those are stamped when Beacon wrote them, so
+// counting them would move an old session to the top of "most recent" the moment it is shared.
+func beaconBookkeeping(action string) bool {
+ return action == "session.shared" || action == "session.commit_linked"
+}
+
// LogSessions lists the sessions in Beacon's runtime log, newest first, narrowed by filter the way
// List narrows a store listing: a runtime, a directory the session ran in or below, and a limit. It
// is how a runtime whose store Beacon does not read, or a session its store no longer has, is found
@@ -96,7 +103,7 @@ func LogSessions(logPath string, filter Filter) ([]Session, error) {
byKey := map[string]*Session{}
var order []string
err := dashboard.StreamEvents(logPath, func(event schema.Event) error {
- if event.Session == nil || strings.TrimSpace(event.Session.ID) == "" {
+ if event.Session == nil || strings.TrimSpace(event.Session.ID) == "" || beaconBookkeeping(event.Event.Action) {
return nil
}
name := canonicalHarness(asymptoteobserve.NormalizeHarnessName(event.Harness.Name))
diff --git a/cli/beacon/internal/handoff/runtimelog_test.go b/cli/beacon/internal/handoff/runtimelog_test.go
index a71fcbcf..bf02a789 100644
--- a/cli/beacon/internal/handoff/runtimelog_test.go
+++ b/cli/beacon/internal/handoff/runtimelog_test.go
@@ -41,3 +41,30 @@ func TestLogSessionsListsByDirectoryNewestFirst(t *testing.T) {
t.Fatalf("kiro sessions = %+v", only)
}
}
+
+func TestLogSessionsIgnoresBeaconBookkeepingForRecency(t *testing.T) {
+ dir := t.TempDir()
+ logPath := filepath.Join(dir, "runtime.jsonl")
+ write := func(action, session, ts string) {
+ t.Helper()
+ event := schema.NewEvent(schema.NewEventOptions{Action: action, Category: "prompt", Harness: schema.HarnessInfo{Name: "kiro"}})
+ event.Timestamp = ts
+ event.Session = &schema.SessionInfo{ID: session, WorkingDirectory: dir}
+ if _, err := writer.AppendEvent(event, writer.Options{Path: logPath, UserMode: true}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ write("prompt.submitted", "older", "2026-10-01T10:00:00.000000000Z")
+ write("prompt.submitted", "newer", "2026-10-01T11:00:00.000000000Z")
+ write("session.shared", "older", "2026-10-01T12:00:00.000000000Z")
+ write("session.commit_linked", "older", "2026-10-01T12:30:00.000000000Z")
+ write("session.shared", "bookkeeping-only", "2026-10-01T13:00:00.000000000Z")
+
+ sessions, err := LogSessions(logPath, Filter{Directory: dir})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(sessions) != 2 || sessions[0].ID != "newer" || sessions[1].ID != "older" {
+ t.Fatalf("sessions = %+v", sessions)
+ }
+}