Skip to content

fix(cli): keep agent-switch reminders in sync with the selected agent - #14279

Merged
marius-kilocode merged 3 commits into
mainfrom
fix-ask-code-mode-toggle-system-prompt
Sep 18, 2026
Merged

marius-kilocode merged 3 commits into
mainfrom
fix-ask-code-mode-toggle-system-prompt

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

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 shared session/reminders.ts and KiloSessionPrompt.

  • All mode reminders now live in one Kilo-owned policy, packages/opencode/src/kilocode/session/mode-reminders.ts.
  • The shared session/reminders.ts is reduced to a single delegation, shrinking the upstream diff.
  • The policy adds one persisted reminder on every agent change. It names the previous and current agent, states that it supersedes earlier agent-switch reminders, and points at the current system prompt as the authority, so project instructions are not released.
  • The capability line is derived from the permission ruleset for native agents. Custom and organization agents get a neutral line, because a scoped allowlist (for example docs/** with a catch-all deny) cannot be summarised correctly from a catch-all check.
  • Plan keeps its per-turn planning instructions.
  • The vestigial KILO_EXPERIMENTAL_PLAN_MODE plan-file hint is dropped, so this change does not depend on that flag.

User Impact

  • Switching back to Ask reinstates the read-only behaviour, so the model refuses edits instead of producing permission noise and an apology.
  • Transitions through custom and organization agents are covered, not only the built-in ask/code pair.
  • Reminders are added only when the agent changes, so same-agent turns are unchanged.

Evidence

  • bun test ./test/kilocode/mode-reminders.test.ts ./test/kilocode/plan-exit-detection.test.ts passes.
  • bun run typecheck is clean in packages/opencode/.
  • bun run script/check-opencode-annotations.ts --worktree passes.
  • Backend run against a local server: code -> ask with 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.

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.
Comment thread packages/opencode/test/kilocode/mode-reminders.test.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/src/kilocode/session/mode-reminders.ts
  • packages/opencode/test/kilocode/mode-reminders.test.ts
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)
  • packages/opencode/test/kilocode/mode-reminders.test.ts

Previous review (commit cfc786a)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/test/kilocode/mode-reminders.test.ts 120 New experimental plan-file hint path is never exercised; the experimental parameter is unused
Files Reviewed (10 files)
  • .changeset/ask-switch-back-reminder.md - 0 issues
  • packages/opencode/src/kilocode/session/agent-switch.txt - 0 issues
  • packages/opencode/src/kilocode/session/mode-reminders.ts - 0 issues
  • packages/opencode/src/kilocode/session/prompt.ts - 0 issues
  • packages/opencode/src/session/reminders.ts - 0 issues
  • packages/opencode/test/kilocode/mode-reminders.test.ts - 1 issue
  • packages/opencode/src/kilocode/session/ask-code-switch.txt (deleted) - 0 issues
  • packages/opencode/src/session/prompt/code-switch.txt (deleted) - 0 issues
  • packages/opencode/test/kilocode/ask-switch-reminder.test.ts (deleted) - 0 issues
  • packages/opencode/test/kilocode/reminders-separator.test.ts (deleted) - 0 issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

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

2 participants