Skip to content

Auto-capture subscribes to session.idle, which opencode 2.x never emits — the feature has never run #136

Closed

Description

@abogartz

Symptom

Auto-capture has never run on any opencode 2.x host. autoCapture: true + a valid captureModel + a live service produces zero auto_capture_* and zero capture_lag evidence lines, and no warning anywhere.

Verified on this machine: zero capture_lag and zero auto_capture_* across the entire 10-day evidence history (~/.config/opencode/memory/evidence/*.logfmt).

Root cause

src/index.ts:1241:

if (event?.type !== "session.idle") continue;

session.idle is not an event opencode 2.x emits — or defines. Three independent lines of evidence:

  1. Live capture. Subscribed to the running desktop service (GET /api/event, SSE, opencode-cli 2.1.4) for 45 s while a fresh session ran a complete turn. 59 events: session.execution.started → session.step.* / session.text.* / session.reasoning.* → session.usage.updated → session.execution.succeeded. No session.idle. No session.status.
  2. Schema. The 2.x event manifest (@opencode/schema/dist/event-manifest.d.ts, session-status-event.d.ts) declares session.status (durability ephemeral) with data: { sessionID, status: { type: "idle" } | { type: "retry", … } }. There is no session.idle event type at all.
  3. Binary. "session.idle" occurs exactly once in the 214 MB 2.1.4 CLI.

This is #78's failure class one layer down: #79 fixed where sessionID is read (src/index.ts:1242), but the type guard rejects every event before that line runs. The envelope fix was correct and useless.

Why the suite missed it

See the companion test-integrity issue: the capture tests fabricate {type:"session.idle"} payloads. Fake and prod are wrong together.

Fix

Do not guess the replacement name — drive it from a recording of the real host stream (the probe method already documented from #86/#90):

  • Key the idle trigger off the session.execution.* end family (succeeded, and the failure/interrupt variants), which is observed live.
  • Also accept session.status with data.status.type === "idle" if the recording shows it firing in other host modes (run --standalone, serve --service, TUI).
  • Keep accepting legacy session.idle only if a recording of an older host shows it.
  • The compaction trigger is separately dead-looking: bench/capture-trigger-results.md reports the compaction world at 0 captured rows / 0/49 with 4 of 6 controls FAIL. Verify it against the same recording.

Acceptance

  • A test driven by a recorded host stream (not a hand-written fake) shows a capture pass firing.
  • Live dogfood: grep ev=capture_lag on a real store returns at least one line.
  • Depends on the plugin_load heartbeat issue so that "armed and inert" is detectable without this audit.

Activity

  1. added
    bug
    capture
    on Oct 26, 2026
  2. abogartz commented on Oct 26, 2026

    @abogartz
    OwnerAuthor

    Correction, before anything builds on this

    The body says "There is no session.idle event type at all." That is wrong. session.idle is declared in @opencode/schema/dist/event-manifest.d.ts (lines 5971 and 5998), as a sibling of session.status with the same data: { sessionID, status: … } shape. I checked for session.status and session.execution.* and concluded from what I looked at, not from what was there.

    The accurate claim, and it is the one that matters:

    session.idle is declared by the protocol and never emitted by the host.

    Verified by 150 s of the running desktop service's own SSE stream (GET /api/event, opencode-cli 2.1.4) covering a complete turn plus 80 s of quiet: session.execution.started → steps → session.usage.updated → session.execution.succeeded, and no session.idle, no session.status.

    Why the correction is load-bearing, not pedantic: it invalidates the obvious fix. "Rename the event to the schema-correct one" would have produced a second dead subscription, because the schema-correct name is also never emitted. It also changes the test design: asserting "every subscribed event name appears in the manifest" — the fix I first wrote — passes on session.idle. The assertion that actually works is "every subscribed event name appears in a recording of the live host." That is what shipped.

    Second correction, on scope: session.idle is not a 1.x compatibility path we are dropping. It entered in 1a83a01 (2026-10-18), one day after the 2.x port 0c939c9 (2026-10-17), and the pre-port plugin never subscribed to the event bus at all — the whole V1-era file mentions "event" once, with no client.event. Auto-capture never worked on any host, in any era.

    Fix: 763906e on fix/capture-trigger-2x. Trigger set is now session.execution.succeeded + session.execution.interrupted, both recorded (the latter by interrupting a live turn). session.status and session.execution.failed are declared but were not observable, so they are deliberately excluded rather than shipped as dead branches.

  3. added a commit that references this issue on Oct 26, 2026
  4. abogartz-opencode-self-improvement commented on Oct 26, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.14.10 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcapturereleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions