Repository navigation
perf(server): OpenCode 2 stops writing unchanged session status updates - #16775
Abdullah1738 wants to merge 1 commit into
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — The adapter now skips redundant session-status persistence while retaining every meaningful status or error transition. The focused regression test covers concurrent threads sharing one OpenCode session, and no schema, default, security, or static-analysis changes are involved. You can add or adjust custom eligibility rules. Learn more. |
Dismissing prior approval to re-evaluate b5288ba
b5288ba to
5a4155a
Compare
|
Note 🤖 Claude Opus 5.5 responding on behalf of Theo The node half of this PR is now on The session-status half is still needed, because #19429 does not touch |
5a4155a to
6dd71aa
Compare
|
Done. Dropped the node cache and its test, kept the session status guard, rebased on main. Updated the title and description to match. |
Dismissing prior approval to re-evaluate 6dd71aa
Problem
OpenCode 2 shares one server session across every thread on an instance, and
ProviderSessionManagerpersists eachprovider_session.updatedonce per attached thread.setSessionStatusemitted on every turn start, finish and request change, even when the status didn't change. With ~80 threads attached, onerunningtorunningcall wrote ~80 events that differed only inupdatedAt.On one machine running OpenCode 2 all day, 348k of that day's 384k session events (91%) were repeats like this, about 0.9 GB of payload before indexes.
Change
setSessionStatusnow returns early whenstatusandlastErrorhaven't changed. Those are the only fields it sets besidesupdatedAt, so every distinct state still gets written, including error changes and a return to an earlier status.updatedAtnow only moves on a real change. Nothing treats it as a heartbeat:ProviderSwitchServiceuses it to pick the newest session, and the OpenCode 2 session id is stable per instance, so that pick doesn't change. Idle tracking reads raw adapter events, not this timestamp.This PR also used to cache the last node per block in the adapter. #19429 now skips unchanged
node.updatedwrites inProviderEventIngestorfor every adapter, so I removed that part and its test.Scope and approval
Theo asked for this shape in this comment: keep the session change, drop the node cache, rebase. Related to #16428, which is the same kind of growth from the ACP adapter.
Verification
OpenCode2AdapterV2.test.tsruns turns on two sessions on the same instance, so the second turn starts and the first one ends while the shared session stays running. It asserts the session reportsrunningandreadyonce each. On main it gets four updates instead of two and fails.packages/provider-opencode,vp fmt --checkandvp linton the touched dirs are clean.updatedAt. I didn't re-measure a live instance after the rebase.Built with Claude Opus 5.5 in T3 Code (OpenCode harness). Reviewed with GPT-6 Astra.