Repository navigation
Description
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:
- 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. Nosession.idle. Nosession.status. - Schema. The 2.x event manifest (
@opencode/schema/dist/event-manifest.d.ts,session-status-event.d.ts) declaressession.status(durabilityephemeral) withdata: { sessionID, status: { type: "idle" } | { type: "retry", … } }. There is nosession.idleevent type at all. - 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.statuswithdata.status.type === "idle"if the recording shows it firing in other host modes (run --standalone,serve --service, TUI). - Keep accepting legacy
session.idleonly if a recording of an older host shows it. - The compaction trigger is separately dead-looking:
bench/capture-trigger-results.mdreports 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_lagon 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
abogartz commentedon Oct 26, 2026
Correction, before anything builds on this
The body says "There is no
session.idleevent type at all." That is wrong.session.idleis declared in@opencode/schema/dist/event-manifest.d.ts(lines 5971 and 5998), as a sibling ofsession.statuswith the samedata: { sessionID, status: … }shape. I checked forsession.statusandsession.execution.*and concluded from what I looked at, not from what was there.The accurate claim, and it is the one that matters:
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 nosession.idle, nosession.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.idleis not a 1.x compatibility path we are dropping. It entered in1a83a01(2026-10-18), one day after the 2.x port0c939c9(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 noclient.event. Auto-capture never worked on any host, in any era.Fix:
763906eonfix/capture-trigger-2x. Trigger set is nowsession.execution.succeeded+session.execution.interrupted, both recorded (the latter by interrupting a live turn).session.statusandsession.execution.failedare declared but were not observable, so they are deliberately excluded rather than shipped as dead branches.Merge pull request #142 from abogartz/fix/capture-trigger-2x
chore(release): 0.14.10 [skip ci]
abogartz-opencode-self-improvement commentedon Oct 26, 2026
🎉 This issue has been resolved in version 0.14.10 🎉
The release is available on:
Your semantic-release bot 📦🚀
fix(capture): fire on turn-end events; session.idle is never emitted (a…