Repository navigation
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Duo-Huang
force-pushed
the
fix/reminders-edge-trigger-custom-agents
branch
from
July 24, 2026 01:35
1750bdd to
a0464ad
Compare
FlyFeathers
added a commit
to FlyFeathers/opencode-fork-
that referenced
this pull request
Jul 24, 2026
1 task done
Duo-Huang
force-pushed
the
fix/reminders-edge-trigger-custom-agents
branch
from
July 27, 2026 05:55
a0464ad to
b345c67
Compare
Duo-Huang
force-pushed
the
fix/reminders-edge-trigger-custom-agents
branch
from
August 10, 2026 01:54
b345c67 to
78c3fbb
Compare
…r build-switch reminder SessionReminders.apply's legacy (!experimentalPlanMode) branch used `messages.some(msg => msg.info.agent === "plan")` to decide whether to inject the BUILD_SWITCH reminder. This checks whether the session has EVER contained a plan-agent message, not whether the immediately preceding turn was plan. With only the built-in plan/build toggle these are nearly equivalent in common usage, but opencode explicitly supports custom primary agents (https://opencode.ai/docs/agents). Once a third primary agent is in rotation (e.g. a custom read-only "ask"-style agent), `.some()` keeps matching build turns for the rest of the (uncompacted) session history -- even many turns after leaving plan, with an unrelated agent in between -- producing a reminder that falsely claims "changed from plan to build" when the actual previous turn was something else entirely. Repeated firing of the same reminder also risks training the model to discount what's meant to be a high-signal system message. Fix by checking only the immediately preceding assistant message's agent, mirroring the findLast-based pattern the experimentalPlanMode branch a few lines below already uses. Observed in production against a live session with a custom read-only 'ask' primary agent: Ask -> build transition incorrectly reproduced the stale 'changed from plan to build' banner from several turns earlier.
Duo-Huang
force-pushed
the
fix/reminders-edge-trigger-custom-agents
branch
from
August 13, 2026 02:20
78c3fbb to
5007223
Compare
Contributor
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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.
Issue for this PR
Closes #38066
Type of change
What does this PR do?
SessionReminders.apply(packages/opencode/src/session/reminders.ts) decides whether to inject the "operational mode has changed from plan to build" reminder using:This checks "has this session ever contained a plan-agent message" (scanning the full uncompacted history), not "was the immediately preceding turn plan". With only the built-in plan/build toggle this rarely matters, but opencode supports custom primary agents (docs/agents). Once a third primary agent is used between plan and build,
wasPlanstays true from the old plan message and the reminder both mislabels the transition and can re-fire on every subsequent build turn.Fix: use
findLastto check only the immediately preceding assistant message's agent, matching the pattern already used a few lines below in theexperimentalPlanModebranch.How did you verify your code works?
Manually reproduced against a real session: switched plan -> custom read-only agent (several turns) -> build. Confirmed the stale "from plan to build" banner still fires on unpatched code, and with this one-line logic change it correctly reflects the immediately preceding agent instead. Did not run the full monorepo test suite in my environment; there's no existing test file for reminders.ts to extend, happy to add one if pointed at a similar fixture.
Screenshots / recordings
N/A, not a UI change.
Checklist