Registry Mirror
Skip to content

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

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 calling submit_plan.

What changed:

  • New 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 for submit_plan and 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.
  • stripConflictingPlanModeRules takes { 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):

  • 2.0.0 through 2.0.22 (tags), 2.0.19 and 2.1.2 binaries, dev at 2.1.3: all send the "Discuss the plan with the user directly ..." reminder (since dbd47702b2, 2026-09-02). The issue is not new in 2.1.
  • Pre-2.0 builds sent "You are in Plan mode. You may optionally create or update plan documents in: ...": also recognized.
  • "STRICTLY FORBIDDEN" is only OpenCode 1's 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 with openCode2, 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 under workflow: "plan-agent" gets the rewritten reminder, the scripted submit_plan opens 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 typecheck and bun run build:opencode pass.

…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
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.

[Bug] OpenCode 2 plan prompt overrides Plannotator; replaceStrictPlanReminder fails to match new reminder text

1 participant