fix(cli): keep agent-switch reminders in sync with the selected agent - #14279
Merged
Merged
Conversation
Switching back from Code to Ask left the earlier Ask-to-Code reminder in history, so the model kept trying to edit files in Ask mode. Replace the name-based switch logic with one central policy that adds a reminder on every agent change, naming the previous and current agent and superseding older reminders. The capability line comes from the permission ruleset for native agents; custom and organization agents get a neutral line because scoped allowlists cannot be summarised safely.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous Review Summaries (2 snapshots, latest commit 655b136)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 655b136)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Previous review (commit cfc786a)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (10 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
Exercise the experimental plan-file hint branch and pin the read-only capability line when switching into the native plan agent. Drop the unused experimental parameter from the apply test helper.
The plan-file hint was gated behind KILO_EXPERIMENTAL_PLAN_MODE, a vestigial flag that is being removed separately. Drop the gated branch so the mode reminder policy does not depend on the flag being deleted, which preserves the shipped default behavior (no hint when the flag is off).
marius-kilocode
enabled auto-merge
September 18, 2026 09:29
WebReflection
approved these changes
Sep 18, 2026
This was referenced Sep 19, 2026
This was referenced Sep 21, 2026
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.
What Problem This Solves
Switching from Ask to Code injected a persisted
<system-reminder>telling the model that the Ask restrictions no longer apply. Switching back from Code to Ask injected nothing, so the stale reminder stayed in history and kept overriding the Ask system prompt. The model then tried to edit files in Ask mode, hit permission denials, and apologised. Plan mode was unaffected because it re-injects its instructions every turn; Ask relies on its system prompt alone.Why This Change Was Made
The switch logic was a name-based special case (
ask -> code) with no reverse path, spread across the sharedsession/reminders.tsandKiloSessionPrompt.packages/opencode/src/kilocode/session/mode-reminders.ts.session/reminders.tsis reduced to a single delegation, shrinking the upstream diff.docs/**with a catch-all deny) cannot be summarised correctly from a catch-all check.KILO_EXPERIMENTAL_PLAN_MODEplan-file hint is dropped, so this change does not depend on that flag.User Impact
ask/codepair.Evidence
bun test ./test/kilocode/mode-reminders.test.ts ./test/kilocode/plan-exit-detection.test.tspasses.bun run typecheckis clean inpackages/opencode/.bun run script/check-opencode-annotations.ts --worktreepasses.code -> askwith an edit request produced "I cannot modify files in ask mode. Switch to the code agent to make this change." with no tool call. Switching to a writable custom agent then created a file, and a scoped custom agent received the neutral capability line rather than a false read-only claim.