Conversation
…an runs OpenCode 2's Plan plugin keeps a reminder at the tail of the plan agent's history telling the model to discuss the plan in chat and not create plan files. The OpenCode 2 adapter only rewrote the old STRICTLY FORBIDDEN text, so the model never called submit_plan. Recognize the reminder by its wrapper and 'You are in Plan mode' (every 2.x wording, plus pre-2.0), replace it with one that asks for submit_plan and keeps OpenCode's plan directory, and strip the new wording and .opencode/plan lines from the system prompt on OpenCode 2 only. The rewrite depends only on the original reminder, so the same history gives the same bytes every request. Fixes #2101
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2101
OpenCode 2's built-in Plan plugin keeps a
<system-reminder>right before the user's prompt in the plan agent's history: "You are in Plan mode. Discuss the plan with the user directly in the conversation. Do not create or update plan files unless the user explicitly asks you to; when they do, write them only in: /.opencode/plan ...". The OpenCode 2 adapter only rewrote the old "STRICTLY FORBIDDEN" text, so this reminder reached the model as is and it wrote the plan into the chat instead of callingsubmit_plan.What changed:
apps/opencode-plugin/plan-reminder.ts: recognizes the reminder by its<system-reminder>wrapper plus "You are in Plan mode" (never the exit reminder, never the person's own words) and replaces it with a Plannotator reminder that asks forsubmit_planand keeps OpenCode's plan directory for a file the user explicitly asks for. The rewrite depends only on the original reminder, so the same history gives the same bytes on every request (prompt cache). The stored message is untouched; OpenCode's Plan hook (a built-in, registered before package plugins) still finds its own reminder by exact text.stripConflictingPlanModeRulestakes{ openCode2: true }from the OpenCode 2 adapter only: it also strips "discuss the plan with the user directly", "do not create or update plan files" and.opencode/plan(s)lines. OpenCode 1 (index.ts) is unchanged.OpenCode versions checked (anomalyco/opencode
packages/core/src/plugin/plan.ts, plus the strings in the published binaries):plan.txt(v1.18.x); that rewrite is kept.Tests:
plan-reminder.test.ts: the exact reminder texts copied from OpenCode's source (2.x enter, pre-2.0 enter, exit, OpenCode 1), Windows directory, idempotence, byte-identical output across requests.plan-mode.test.ts: the new strip rules withopenCode2, and the same lines kept without it.server.test.ts: the context hook rewrites the reminder for the plan agent, same bytes on the next request, left alone for build.inbox-v2.test.ts(the real OpenCode 2 with the packed plugin and a scripted model): a plan-agent session underworkflow: "plan-agent"gets the rewritten reminder, the scriptedsubmit_planopens a review, and Approve comes back as the tool result. Passes on 2.0.19 and 2.1.2; fails on the plugin from main.bun test apps/opencode-plugin: 394 pass, 7 skip (the real-host ones), 0 fail.bun run typecheckandbun run build:opencodepass.