Skip to content

feature: abctl: better user help for disappearing events #870

Closed

Description

@esnible

Feature Description

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"
  • ? other ideas?

Want to contribute?

  • I would like to work on this issue.

Additional Context

No response

Activity

  1. esnible commented on Sep 9, 2026

    @esnible
    MemberAuthor

    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:

    for id := range m.events {
        if !serverIDs[id] { delete(m.events, id) }
    }
    if m.selectedSess != "" && !serverIDs[m.selectedSess] && m.pane != paneSessions {
        m.selectedSess = ""; m.pane = paneSessions   // silent focus steal
    }

    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.

    Assisted-By: Claude (Anthropic AI) [email protected]

  2. added
    high priority
    on Sep 10, 2026
  3. added this to the Release V0.9.0 milestone on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

high priority

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions