Skip to content

fix(T700): OpenCode v2 places the resume note and never drops it on a receipt - #376

Merged
kryptobaseddev merged 1 commit into
mainfrom
fix/t700-v2-resume-note
Oct 18, 2026
Merged

kryptobaseddev merged 1 commit into
mainfrom
fix/t700-v2-resume-note

Conversation

@kryptobaseddev

Copy link
Copy Markdown
Owner

OpenCode 9dddcd9 (base 65f9040). Fixes the live T187 failure on 0.5.48 (OpenCode 2.0.32, v2 plugin path). Two causes:

  1. session.execution.started marked the turn before the first tool.execute.after, so the note could never ride a tool result.
  2. At stop, resume:false queue admission returned a receipt but wrote no session message, so the note was acknowledged and dropped.

Fix (opencodePluginSource only):

  • The first tool of a turn may place the note, and a kept note is deleted only after placement succeeds.
  • Stop no longer injects a kept note; it rides the next turn's first tool result. Admitting with resume:true would start an unwanted turn on an idle TUI.
  • A fresh conversation's start note keeps its queued admission (T187 AC1).

New v2 harness tests in test/opencode-resume.test.ts went red→green (3 failures before, 8/8 after). Two opencode-hooks tests that encoded the superseded drop-on-receipt contract are updated. opencode-* suites 206/207 (1 pre-existing skip), tsc clean, no dist drift. CHANGELOG Unreleased only. A live re-check needs a service restart after release.

🤖 Generated with Claude Code

… receipt

OpenCode 2.x drives the plugin default `setup(ctx)` path and marks a turn at
`session.execution.started` before the first tool. The busy-turn guard then
treated every tool as mid-turn, so a revisit notice could only fall back; at
the turn's end the plugin admitted it with `resume:false`, whose msg_ receipt
can arrive without a session_message (T544), and discarded the pending copy.

- Track tools-per-turn so the first tool of a turn places the note even when
  the v2 start event already marked the turn.
- Drop a kept note only after it actually lands in a tool result. A stop no
  longer admits it through a receipt; `resume:true` is not used because
  starting a turn on an idle TUI is not the job of a resume note.
- Keep a fresh conversation's start note on its existing queued admission,
  which the host materialises as the conversation begins.
- Add v2 harness tests for both failures; update the two T187 hook tests that
  encoded the old receipt-retry contract.

Checks: the two v2 tests fail on the pre-fix template and pass after it;
opencode-resume, opencode-hooks, opencode-no-duplicate-loop,
opencode-poller-wake, the full opencode-* suite, tsc --noEmit, npm run build.
@kryptobaseddev
kryptobaseddev merged commit 29e7329 into main Oct 18, 2026
1 check passed
@kryptobaseddev
kryptobaseddev deleted the fix/t700-v2-resume-note branch October 18, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant