-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Mode-specific rules are applied to all agents instead of only the active agent #7507
Description
Problem
Mode-specific rule files (e.g. .kilocoderules-code, .kilo/rules-code/*.md) are loaded into the generic instructions array alongside non-mode-specific rules. This means all mode-tagged rules are injected into the system prompt for every agent, regardless of which agent/mode is currently active.
For example, if a project has:
.kilocoderules-code(rules for thecodemode).kilocoderules-architect(rules for thearchitectmode).kilo/rules/general.md(generic rules)
All three files are included in the system prompt even when only the code agent is active. The architect-specific rules should not be present when running in code mode, and vice versa.
Additional issue: custom mode rules are never discovered
Custom modes defined in .kilocodemodes are not scanned for rule directories. The rule discovery logic uses a hardcoded KNOWN_MODES list (code, architect, ask, debug, orchestrator), so if a user defines a custom mode (e.g. translate) and creates a corresponding .kilo/rules-translate/ directory, those rules are silently ignored.
Expected behavior
- Mode-specific rules should only be injected into the system prompt for the matching active agent/mode. Generic rules (non-mode-tagged) should continue to apply to all agents.
- Custom modes defined in
.kilocodemodesshould have their rule directories discovered alongside the built-in modes, so that.kilo/rules-{custom-mode}/*.mdand.kilocoderules-{custom-mode}files are properly loaded.
Steps to reproduce
- Create a project with mode-specific rules for multiple modes:
.kilocoderules-code -> "# Code-only rules" .kilocoderules-architect -> "# Architect-only rules" - Start a session with the
codeagent - Inspect the system prompt — both
codeandarchitectrules are present
For the custom mode issue:
- Define a custom mode
translatein.kilocodemodes - Create
.kilo/rules-translate/glossary.md - Start a session with the
translateagent - The glossary rules are never loaded
Related PR
Metadata
Metadata
Assignees
Labels
Type
Projects
Status