Skip to content

[bug] opencode v2 /acp wakes the model on every invocation (spurious empty turns) #876

Closed

Description

@ranxianglei

Found while live-testing PR #850's /acp (OpenCode V2 native plugin) in a real opencode v2.0.4 TUI behind bili.

Symptom

Every /acp invocation starts a full model turn although the user typed nothing after it: extra upstream forwards immediately after /acp, spurious empty assistant turns, token spend loops. Repro: v2.0.4 TUI, send one real message, run /acp once → proxy forward count grows; repeat → grows again.

Root cause (official v2.0.4 source)

src/agent/opencode-v2.ts called ctx.session?.synthetic?.({ sessionID, text }) with no resume field. Core Session.synthetic (packages/core/src/session/session.ts): default delivery: input.delivery ?? "steer" and
if (input.resume !== false && !(yield* get(sessionID)).revert) yield* execution.wake(sessionID)
so every /acp rendered the panel AND woke the executor: a steer item entered the inbox and a model turn ran with no user input. (The platform uses wake deliberately for subagent-completion notifications — our status render misused that channel.)

Fix

Pass resume: false. Verified live in v2.0.4: identical panel render, zero model requests after /acp (proxy forward count frozen).

Fixed in branch 2026-09-17_opencode-v2-acp-no-wake (stacked on #850).

Activity

  1. ranxianglei commented on Sep 17, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    [bot] 🏷 Verified the fix end-to-end on 2026-09-17_opencode-v2-acp-no-wake.

    Root cause confirmed. Matches the v2.0.4 core semantics you cited: session.synthetic() defaults to delivery: "steer" and calls execution.wake(sessionID) unless resume === false, so every /acp status render injected a steer item AND started a model turn with no user input. The fix (resume: false) is the correct minimal intervention — rendering stays inert while the panel still delivers as a synthetic message.

    Fix state. Commit d6d60f8 ("fix(agent): /acp must not wake the model under OpenCode V2") changed the single call site at src/agent/opencode-v2.ts:271 to synthetic?.({ sessionID: sid, text, description, resume: false }) and extended the V2PluginContext.session.synthetic type with resume?: boolean / description?: string. Tests now assert the flag: tests/opencode-v2.test.ts:361,381 (assert.equal(fake.syntheticCalls[0].resume, false)). Grep confirms no other synthetic( call site in src/ lacks the flag.

    PR trail. Already shipped as PR #875 ("fix(agent): /acp must not wake the model under OpenCode V2", body carries Fixes #876) — merged into the head of PR #850 (2026-09-15_opencode-native-plugin). Per the stack convention this lands on master when #850 → feat/pi-native-plugin (#706) merges; the issue then auto-closes via the Fixes #876 reference. No second PR opened (one issue → one PR).

    Local pre-flight on the branch:

    • npm run typecheck — clean
    • npm test — 1659 pass / 0 fail / 2 skipped (incl. all 17 opencode-v2.test.ts cases)

    结论:验证通过——根因成立(v2 synthetic() 默认 steer+wake,每次 /acp 都白跑一轮模型),修复正确且最小(resume: false,唯一调用点已覆盖、测试断言到位);修复已在 PR #875 合入 #850 的堆叠分支,本地 typecheck + 全量测试通过,待堆叠 PR 依次合并后随栈落 master,本 issue 自动关闭。

  2. ranxianglei commented on Sep 17, 2026

    @ranxianglei
    OwnerAuthor

    继续

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions