Skip to content

fix(capture): read session.idle and message.updated from the 2.x data envelope - #79

Merged
abogartz merged 1 commit into
abogartz:mainfrom
WhollyMindless:fix/capture-2x-envelope
Oct 24, 2026
Merged

abogartz merged 1 commit into
abogartz:mainfrom
WhollyMindless:fix/capture-2x-envelope

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

Closes #78, done as the issue specifies.

Change (src/index.ts):

  • session.idle (line 919): event.sessionID ?? event.properties?.sessionID ?? event.data?.sessionID, your one-liner.
  • message.updated (line 856): ev.properties?.info ?? ev.info ?? ev.data?.info. This came out of the audit you suggested, below.

Both are additive fallbacks, so the 1.x shapes behave exactly as before.

The audit of reads on the event-bus path:

Read Before 2.x-safe? Change
Identity (session.created / execution.started / moved), line 847 ev.data ?? ev.properties yes none
Measured usage (message.updated), line 856 ev.properties?.info ?? ev.info no: "both" here meant properties and top-level, not data add ?? ev.data?.info
Auto-capture (session.idle), line 919 event.sessionID ?? event.properties?.sessionID no (#78) add ?? event.data?.sessionID

Capture reads nothing else from the bus event. The evidence for message.updated is @opencode/schema 2.0.32's dist/v1/session.d.ts (the version in this repo's bun.lock). It types the event as { type: "message.updated", …, data: { sessionID, info } }, the same envelope as session.idle.

One thing only you can check: if the measured cache figure in memory_status or the TUI badge shows real numbers on your 2.x host, then the bus is delivering properties or top-level info there after all, and this second fallback is just a harmless extra read. If it has always read "not measured", this fixes it too.

Tests, both with a fake 2.x-shape host, payload under data:

  • test/capture.test.ts: { type: "session.idle", data: { sessionID } } calls the capture model and writes an auto_capture_* evidence row.
  • test/status.test.ts: { type: "message.updated", data: { info } } lands the measured usage in the status file.

The existing 1.x-shape tests are unchanged. With the source change reverted, both new tests fail: capture times out with no model call, and measured stays undefined.

Checks (Linux, Bun 1.4.4, on 0.8.8): bun test ./test/ 326 pass, 4 skip, 0 fail. bun run test:e2e against opencode 2.0.26: 9 pass. tsc --noEmit is clean, and biome lint exits 0 with warnings unchanged from main.

🤖 Generated with Claude Code

… envelope

On opencode 2.x the bus payload is under event.data. Auto-capture read
only sessionID/properties.sessionID, so every session.idle was skipped
and capture never ran. The measured-usage handler likewise missed
data.info. Both now fall back to event.data, the same defensive read the
identity handler already uses. Tests use a 2.x-shape fake host.

Closes abogartz#78.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abogartz
abogartz merged commit 959998f into abogartz:main Oct 24, 2026
3 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.8.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

abogartz pushed a commit that referenced this pull request Oct 25, 2026
…er eats it

The compaction cliff is where episodic detail dies: one round retains ~53%
of exact-wording rules. The session.compaction hook already pushes the
memory anchor onto the summarizer's system parts; now it ALSO fires the
auto-capture pipeline (same runWriteGate path as the idle trigger - never
a direct write) against the hook payload's PRE-compaction transcript, so
the facts are mined while they still exist.

Rows land tagged auto-capture + auto_capture_compaction, evidence as
auto_capture_compaction_<action> with a trigger field on every capture
line, so decay/status can attribute capture by trigger and the real-world
hit-rate comparison is log analysis, not new plumbing. captureOnCompact
defaults on under the autoCapture master switch (zero-token default
unchanged; setting it alone warns instead of silently costing tokens).
Cooldowns are per-session AND per-trigger so measuring one trigger is not
confounded by the other. Payload-less hosts fall back to session.context
- the #79 envelope lesson, pinned by test.

bench/capture-trigger-compare.ts measures the claim (49 queries, 3 worlds,
6 self-checks incl. a must-fail negative control): R@3 43% at-compaction
vs 24% idle-after-the-cliff vs 0% off; the bench EXITS RED on src without
this commit.

Fixes #41.
abogartz-opencode-self-improvement Bot pushed a commit that referenced this pull request Oct 25, 2026
# [0.14.0](v0.13.2...v0.14.0) (2026-10-25)

### Features

* **capture:** mine the transcript AT compaction, before the summarizer eats it ([c531e27](c531e27)), closes [#79](#79)
@WhollyMindless
WhollyMindless deleted the fix/capture-2x-envelope branch October 26, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-capture is silently dead on opencode 2.x: session.idle envelope read misses event.data

2 participants