Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(cli): inject agent-switch reminder when switching from Code back to Ask - #14069

Open
Sayandevxyz wants to merge 1 commit into
Kilo-Org:mainfrom
Sayandevxyz:fix/code-ask-switch-reminder
Open

fix(cli): inject agent-switch reminder when switching from Code back to Ask#14069
Sayandevxyz wants to merge 1 commit into
Kilo-Org:mainfrom
Sayandevxyz:fix/code-ask-switch-reminder

Conversation

@Sayandevxyz

Copy link
Copy Markdown

Fixes #14060

Summary of Changes

When switching from Ask to Code, Kilo injects a <system-reminder> notifying the model that it has switched to Code mode. However, when switching back from Code to Ask, insertAgentSwitchReminder previously exited early with if (mode(input.agent.name) !== "code") return, leaving the model unaware of the transition and often attempting file edits or commands prohibited in Ask mode.

This PR:

  • Adds code-ask-switch.txt reminder instructing the agent that it is now in read-only Ask mode.
  • Updates insertAgentSwitchReminder in packages/opencode/src/kilocode/session/prompt.ts to inject the appropriate reminder for both Ask → Code and Code → Ask transitions.
  • Adds comprehensive unit tests in packages/opencode/test/kilocode/ask-switch-reminder.test.ts verifying injection, message text, and deduplication.
  • Includes a patch changeset for @kilocode/cli.

Test Plan

  • Run unit tests: bun test ./test/kilocode/ask-switch-reminder.test.ts (all 11 tests pass).
  • Verify annotations: bun run script/check-opencode-annotations.ts --worktree (clean pass).

@kilo-code-bot

kilo-code-bot Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

lgtm

The transition detection in insertAgentSwitchReminder now covers both directions, prior-message lookup is safe (agent is a required string on user and assistant messages), dedup only inspects the current user message's parts, and the new tests exercise injection, non-injection, and deduplication with real implementation. No memory, security, or fork-hygiene concerns in the changed code.

Files Reviewed (4 files)
  • .changeset/code-ask-switch-reminder.md
  • packages/opencode/src/kilocode/session/code-ask-switch.txt
  • packages/opencode/src/kilocode/session/prompt.ts
  • packages/opencode/test/kilocode/ask-switch-reminder.test.ts

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

Review guidance: REVIEW.md from base branch main

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.

Mode switch system-reminder not injected when switching from Code back to Ask

1 participant