You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature: abctl: better user help for disappearing events #870
Sometimes I am debugging and abctl shows many events. Then I am interrupted and return, and the events I was analyzing are gone!
This feature is to help the user deal with event lifetime in abctl.
Proposed Solution
It is unclear to me which component "lost" the events. Did Cortex expire them because they were too old? Did Cortex forget about a pipeline that hasn't had an event in the last 5 minutes?
We have choices
When Cortex detects an abctl sessions is there, lock the events and pipelines from expiration
When abctl notices events vanishing, leave them on a screen with some kind of notice "details have expired"
Diagnosis: the events are deleted by abctl itself, not expired by Cortex
Investigated this. The issue's leading hypothesis — Cortex expiring events for being too old — is almost certainly not what happens. All four real mechanisms are below, most likely first.
Ruled out: server-side TTL expiry
session.TTL defaults to never. Both authlib/config/config.go:212 and authlib/session/store.go:495-507 say so explicitly, and store.go:144 does not even start the reaper goroutine when ttl <= 0. So "Cortex expired them because they were too old" only occurs if session.ttl was set explicitly in YAML.
There is also no "forget a pipeline that hasn't had an event in 5 minutes" rule anywhere in the tree.
This matters for the proposed solutions: "when Cortex detects an abctl session, lock the events and pipelines from expiration" would not help, because nothing expired. The client deleted its own copy.
Cause 1 (primary): abctl deletes cached events for any session the server stops listing — every 2 seconds
cmd/abctl/tui/app.go:597-616, on each sessionsLoadedMsg:
refreshInterval = 2 * time.Second (app.go:114) and the refresh fires loadSessionsCmd() unconditionally regardless of pane (app.go:675). Any session that leaves the server list takes the user's on-screen events with it and bounces them out of the pane they were reading — with no flash or banner explaining why.
This is deterministic for the common single-agent configuration where nearly every session is named default. After a proxy restart ListSessions returns an empty slice, which is not an error (apiclient/client.go:54-62), so it becomes a normal sessionsLoadedMsg. serverIDs is empty, every cached session is deleted, and the user is thrown back to the sessions pane within one 2s tick. No traffic needs to arrive — the deletion is caused by the absence of the session, and waiting cannot help because nothing is left to restore. The store is per-pod and non-persistent (store.go:1-3), so the history exists nowhere afterwards.
The reconcile was written for exactly one job: garbage-collecting the bootstrap default bucket after Rekey moves events to a server-assigned contextId (app.go:598, store.go:420). That assumes default is a transient artifact whose contents moved elsewhere and are still on screen. For a single-agent pod with no explicit A2A SessionID — the shape store.go:16-20 documents as intended — that assumption is inverted: default is the permanent bucket holding everything. The one bucket the code treats as safe to discard is the only one that exists.
Not restart-specific either. Any transient empty/missing report — restart, maxSessions eviction, a recovered fetch — costs the whole cache 2s later.
Cause 2: a proxy restart silently wipes the server store
In-memory, per-pod (store.go:1-3). abctl service restart empties it. abctl reconnects (connReconnecting, app.go:732) and cause 1 then garbage-collects the local cache. Nothing distinguishes this from an idle session.
Cause 3: two per-session caps that disagree
Server maxEvents defaults to 500 (config.go:216); client maxEventsPerSession = 1000 (app.go:76), whose comment claims "Matches the server's default maxEvents cap". It is 2x. Both FIFO-trim oldest (app.go:1057, store.go:226).
Cause 4: silent SSE drops, and a drop counter that is always zero
store.go:518-526 discards events non-blockingly when a subscriber's 64-deep channel fills. The server logs the lag (sessionapi/server.go:386-390) but only to its own slog — it never goes on the wire. Meanwhile abctl's footer renders drops: N from m.drops (footer.go:39-40), and m.drops is never incremented anywhere — only zeroed at app.go:426. The one indicator a user would check to detect loss is hardcoded to drops: 0, which actively misleads during exactly this debugging session.
Why both current behaviors are wrong for a viewer
The pane change and the delete are consequences of one decision: treating the server's session list as authoritative over client display state. The server's list should govern what is live, not what is viewable.
The pane change is justified at app.go:599-601 as avoiding "an empty events view" — but the view is only empty because of the delete two lines earlier. Fix the delete and the premise disappears. Its guard is m.pane != paneSessions, so it also fires from the detail pane, discarding a specific drilled-into event.
Keeping the pane open is safe, verified rather than assumed: m.events[m.selectedSess] on a missing key returns a nil slice (events_pane.go:81), buildEventRows over nil yields no rows, and selectedEventRow guards both empty rows and out-of-range cursors (events_pane.go:182-188). Worst case degrades to an empty table, not a panic.
The delete is the only irreversible action in the flow, and what it buys — memory — is already bounded by maxEventsPerSession and the number of sessions actually visited. Deferring cleanup until the user selects a different session puts eviction at the point where the data has demonstrably stopped being interesting, decided by the only party who knows.
The issue's second option — leave them on screen with a notice — is the right instinct and the correct fix for cause 1. The notice must not say "expired", since the real reasons are restart, eviction, or overflow.
Intended behavior
Trigger
Now
Should be
Empty session list (restart)
wipe all + pane change
keep everything, banner "proxy restarted"
One session evicted server-side
wipe it + pane change
keep, mark not-live
Genuine rekey
wipe default
re-key the cache to the new ID
User selects another session
nothing
now drop the old cache if bounding is needed
Three of four cases should stop deleting, one should migrate instead of delete, and the pane should never change on its own.
Causes 3 and 4 are independent pre-existing bugs (dead m.drops, wrong cap comment) and are probably worth their own issues rather than being folded in here.
Activity
esnible commentedon Sep 9, 2026
Diagnosis: the events are deleted by
abctlitself, not expired by CortexInvestigated this. The issue's leading hypothesis — Cortex expiring events for being too old — is almost certainly not what happens. All four real mechanisms are below, most likely first.
Ruled out: server-side TTL expiry
session.TTLdefaults to never. Bothauthlib/config/config.go:212andauthlib/session/store.go:495-507say so explicitly, andstore.go:144does not even start the reaper goroutine whenttl <= 0. So "Cortex expired them because they were too old" only occurs ifsession.ttlwas set explicitly in YAML.There is also no "forget a pipeline that hasn't had an event in 5 minutes" rule anywhere in the tree.
This matters for the proposed solutions: "when Cortex detects an abctl session, lock the events and pipelines from expiration" would not help, because nothing expired. The client deleted its own copy.
Cause 1 (primary):
abctldeletes cached events for any session the server stops listing — every 2 secondscmd/abctl/tui/app.go:597-616, on eachsessionsLoadedMsg:refreshInterval = 2 * time.Second(app.go:114) and the refresh firesloadSessionsCmd()unconditionally regardless of pane (app.go:675). Any session that leaves the server list takes the user's on-screen events with it and bounces them out of the pane they were reading — with no flash or banner explaining why.This is deterministic for the common single-agent configuration where nearly every session is named
default. After a proxy restartListSessionsreturns an empty slice, which is not an error (apiclient/client.go:54-62), so it becomes a normalsessionsLoadedMsg.serverIDsis empty, every cached session is deleted, and the user is thrown back to the sessions pane within one 2s tick. No traffic needs to arrive — the deletion is caused by the absence of the session, and waiting cannot help because nothing is left to restore. The store is per-pod and non-persistent (store.go:1-3), so the history exists nowhere afterwards.The reconcile was written for exactly one job: garbage-collecting the bootstrap
defaultbucket afterRekeymoves events to a server-assignedcontextId(app.go:598,store.go:420). That assumesdefaultis a transient artifact whose contents moved elsewhere and are still on screen. For a single-agent pod with no explicit A2ASessionID— the shapestore.go:16-20documents as intended — that assumption is inverted:defaultis the permanent bucket holding everything. The one bucket the code treats as safe to discard is the only one that exists.Not restart-specific either. Any transient empty/missing report — restart,
maxSessionseviction, a recovered fetch — costs the whole cache 2s later.Cause 2: a proxy restart silently wipes the server store
In-memory, per-pod (
store.go:1-3).abctl service restartempties it.abctlreconnects (connReconnecting,app.go:732) and cause 1 then garbage-collects the local cache. Nothing distinguishes this from an idle session.Cause 3: two per-session caps that disagree
Server
maxEventsdefaults to 500 (config.go:216); clientmaxEventsPerSession = 1000(app.go:76), whose comment claims "Matches the server's default maxEvents cap". It is 2x. Both FIFO-trim oldest (app.go:1057,store.go:226).Cause 4: silent SSE drops, and a drop counter that is always zero
store.go:518-526discards events non-blockingly when a subscriber's 64-deep channel fills. The server logs the lag (sessionapi/server.go:386-390) but only to its own slog — it never goes on the wire. Meanwhileabctl's footer rendersdrops: Nfromm.drops(footer.go:39-40), andm.dropsis never incremented anywhere — only zeroed atapp.go:426. The one indicator a user would check to detect loss is hardcoded todrops: 0, which actively misleads during exactly this debugging session.Why both current behaviors are wrong for a viewer
The pane change and the delete are consequences of one decision: treating the server's session list as authoritative over client display state. The server's list should govern what is live, not what is viewable.
app.go:599-601as avoiding "an empty events view" — but the view is only empty because of the delete two lines earlier. Fix the delete and the premise disappears. Its guard ism.pane != paneSessions, so it also fires from the detail pane, discarding a specific drilled-into event.m.events[m.selectedSess]on a missing key returns a nil slice (events_pane.go:81),buildEventRowsover nil yields no rows, andselectedEventRowguards both empty rows and out-of-range cursors (events_pane.go:182-188). Worst case degrades to an empty table, not a panic.maxEventsPerSessionand the number of sessions actually visited. Deferring cleanup until the user selects a different session puts eviction at the point where the data has demonstrably stopped being interesting, decided by the only party who knows.The issue's second option — leave them on screen with a notice — is the right instinct and the correct fix for cause 1. The notice must not say "expired", since the real reasons are restart, eviction, or overflow.
Intended behavior
defaultThree of four cases should stop deleting, one should migrate instead of delete, and the pane should never change on its own.
Causes 3 and 4 are independent pre-existing bugs (dead
m.drops, wrong cap comment) and are probably worth their own issues rather than being folded in here.Assisted-By: Claude (Anthropic AI) [email protected]
fix: Address review on event retention
fix: Unstyle the gone cell, and stop the two remaining delete paths
fix: Promote termenv to a direct dependency
fix: Rebuild the sessions table after freeing tombstones
fix: Prove the rekey with CreatedAt instead of guessing from list shape
test: Make the declined-migration test actually reach that path
docs: Add the missing TOKENS column, and pin it against future drift
fix: Don't release cached-only sessions, and don't snapshot them
Fix: Keep abctl's cached events across proxy restarts (rossoctl#933)
fix(abctl): read the selected session id out of band, not off the ren…
feat(abctl): replace ACTIVE with a CONTEXT(1M) gauge
feat(abctl): Merge the server's prompt-context figure into the gauge
perf(abctl): Merge the gauge's two figures without allocating per row
Docs: Correct the vanishing-title claim, and gate the fixture that wa…
Docs: Correct the vanishing-title claim, and gate the fixture that wa…