Implement organization custom modes support in the new extension
Summary
Organization custom modes are not available in the new Kilo Code extension. Personal custom modes migrate and work correctly, but organization-level custom modes — which were fully functional in the legacy extension (kilocode-legacy) — are missing entirely. This was reported by a user (Lígia Zanchet) via our feedback channel.
How Organization Custom Modes Worked in the Legacy Extension
In kilocode-legacy, organization custom modes had a complete end-to-end implementation:
Fetching
- Organization modes were fetched from the Kilo API:
GET https://api.kilo.ai/api/organizations/{organizationId}/modes - Requests included the
Authorization: Bearer {token}andX-KiloCode-OrganizationId: {orgId}headers - Implemented in
CustomModesManager.fetchOrganizationModes()atsrc/core/config/CustomModesManager.ts
Triggers
Org modes were fetched on two occasions:
- Extension startup — via
fetchAndRefreshOrganizationModesOnStartup()when bothkilocodeTokenandkilocodeOrganizationIdwere present - Organization switch — when the user changed their organization via the
OrganizationSelectordropdown
Storage & Merging
- Org modes were not stored on disk — they lived in VS Code
globalStateunder the"customModes"key, merged with local modes - A three-tier precedence system was enforced: Organization > Project > Global
- If an org mode had the same slug as a personal/project mode, the org mode always won
- Each mode had a
sourcefield:"global","project", or"organization"
UI
- KiloModeSelector: Separated modes into "Organization Modes" (with
codicon-organizationicon) and other modes, with a visual separator - ModesView: Showed a read-only
OrganizationModeWarningbanner for org modes, linking to the Kilo dashboard (https://kilo.ai/organizations/{orgId}/custom-modes) for editing - Agent Manager: Org modes were temporarily filtered out with a TODO comment
Type System
ModeConfigincludedsource: z.enum(["global", "project", "organization"]).optional()— the discriminator for org modes
What Currently Exists in the New Extension
Personal Custom Modes — Working
Personal custom modes work through multiple mechanisms:
- Markdown files:
.kilo/agents/*.md,.kilo/modes/*.md— project-scoped - Config JSON:
kilo.json/opencode.jsonunder theagentkey - Legacy migration:
ModesMigratorreadscustom_modes.yamland.kilocodemodesfiles and converts them to the new agent format - Marketplace: Install community modes from
api.kilo.ai/api/marketplace/modes - AI generation:
Agent.generate()creates agent config from natural language
Organization Infrastructure — Partial
The auth/organization system exists:
- Login via OAuth, profile fetching with organizations list
AccountSwitcher.tsxfor org switching- Org context flows through to models (
/api/organizations/{orgId}/models) and balance POST /kilo/organizationswitches the active org
Organization Modes — Missing
- The
KilocodeModeinterface inmodes-migrator.tshassource?: "global" | "project" | "organization"but this field is never populated - The
Agent.Infoschema inagent.tshas nosourcefield at all - There is no endpoint in kilo-gateway for fetching organization modes
- The
GET /agentserver endpoint returns agents from local config only — no org-aware fetching - The design doc at
packages/kilo-docs/pages/contributing/architecture/organization-modes-library.mddescribes this as a planned feature
What Needs to Be Added/Changed
1. kilo-gateway (packages/kilo-gateway/)
- Add a new route to fetch organization modes, e.g.,
GET /kilo/organization/modes - Call the existing backend API:
GET https://api.kilo.ai/api/organizations/{orgId}/modes - Pass auth token and org ID context from the current session
2. CLI Server (packages/opencode/src/server/)
- Expose the new gateway route or integrate org modes into the existing
GET /agentendpoint - Org modes should be merged with local agents, respecting precedence (org > project > global)
3. Agent/Config System (packages/opencode/src/)
- Add a
sourcefield toAgent.Infoschema to distinguish org vs local agents - Convert the API response format (legacy
ModeConfigwithroleDefinition,groups) to the new agent format - Implement precedence: org modes override same-name local agents and built-in agents
4. SDK (packages/sdk/js/)
- Regenerate after adding new endpoints
- Ensure
AgentInfotype includessourcefield
5. Extension (packages/kilo-vscode/)
- If org modes are merged server-side into
Agent.list(), the existingfetchAndSendAgents()flow should pick them up automatically - Add
sourcetoAgentInfotype in webview messages - Trigger agent refresh on org switch (currently only models/balance refresh)
6. Webview UI
- Visually distinguish org-provided agents in
ModeSwitcher(e.g., org icon, grouping) - Make org agents non-removable / non-editable in
AgentBehaviourTab - Consider a read-only indicator linking to the Kilo dashboard for editing
Context
- Personal custom modes migrate correctly from the legacy extension and work end-to-end
- The organization auth/switching infrastructure already exists
- The Kilo backend API for org modes (
/api/organizations/{orgId}/modes) already exists (used by the legacy extension) - A design doc exists at
packages/kilo-docs/pages/contributing/architecture/organization-modes-library.md - The legacy implementation in kilocode-legacy serves as a reference for the expected behavior
Hi, we're a small team using Kilo Code with a fully git-versioned custom mode setup. We ran into the gap described below and wanted to share it as a real-world use case, since it seems directly relevant to what you're building here.
Built-in modes are not versionable — and the built-in orchestrator ignores custom mode routing
Summary
Kilo Code's built-in modes (architect, code, debug, ask, orchestrator) are defined inside extension.js. There is no supported mechanism to version-control or cleanly override them. More critically: the built-in orchestrator routes to these fixed slugs regardless of whether a more specialized custom mode exists — which undermines the entire purpose of the whenToUse field.
Background: How we manage custom modes
We manage all custom modes as Markdown files in a git repository with a lifecycle pipeline:
IDE/kilocode/custom-modes/
01_draft/ ← in development
02_dev/ ← under review
03_active/ ← deployed to custom_modes.yaml
03_active/special-ops/ ← system-level modes
99_inactive/ ← archived
A deployment step writes active modes into OPS/custom-modes/custom_modes.yaml — our single source of truth. This file is versioned in git alongside rules, references and templates. Changes are diffable, reviewable, and rollback-capable.
Each mode has:
- A canonical
.mdsource file with frontmatter, role, instructions, changelog - A versioned slug (e.g.
specialist-architect-v3,specialist-coder-v4) - A
whenToUsefield that describes when to activate the mode
To close the gap between the git repo and the live IDE, we use a symlink manager that links runtime paths (where Kilo Code expects its config files) directly to the versioned repo. It validates each link — detecting wrong type, wrong target, or missing links — and prevents drift between repo state and what the IDE actually loads.
This means our entire custom mode setup is reproducible, auditable, and drift-free. We have the infrastructure for 100% reproducibility. It breaks exactly at the built-in layer — because built-in modes live inside extension.js, outside the reach of any symlink, any YAML, and any git history.
Problem 1: Built-in modes live in extension.js — not in user config
The built-in mode definitions (architect, code, debug, etc.) are bundled inside the extension binary. This means:
- No editability: We cannot adjust built-in mode behavior without modifying
extension.js— a minified multi-MB bundle containing the entire extension logic. Not a realistic option. - No versioning path: There is no supported mechanism to export, override, or track built-in mode definitions alongside user-managed custom modes.
We worked around this by creating fully custom replacements for each built-in role, with whenToUse fields explicitly directing users away from the originals. This works for manual mode selection — but not for orchestrator-driven workflows.
Problem 2: The built-in orchestrator ignores whenToUse — routes by hardcoded slug
The built-in orchestrator routes subtasks to modes by slug. It delegates to architect, code, debug — regardless of what custom modes exist or what their whenToUse fields say.
The core issue: whenToUse is the intended signal for "prefer this mode when X applies." If a team has built a specialized architect mode or a specialized coder mode with domain-specific instructions, the orchestrator has no mechanism to discover or prefer it. It routes to the generic built-in by default.
Our current workaround: We are building a custom orchestrator mode with explicit routing instructions that map task types to our custom slugs. This is functional but fragile — it duplicates routing logic that should be configuration, requires manual upkeep as the mode roster changes, and only works if the custom orchestrator is explicitly selected.
What we'd expect
Option A — Slug-based override in custom_modes.yaml:
Allow a custom mode to declare overrides: architect to fully replace a built-in — including in orchestrator routing. The custom definition takes precedence everywhere.
Option B — Configurable orchestrator routing:
Add a routing config section (e.g. in settings.json or custom_modes.yaml) where users can map built-in slugs to custom mode slugs:
orchestratorRouting:
architect: my-specialist-architect
code: my-specialist-coder
debug: my-specialist-debugger
Option C — whenToUse-aware orchestrator:
Allow the orchestrator to evaluate whenToUse fields across all active modes — including custom ones — and prefer a specialized custom mode over a generic built-in when the conditions match.
Why this matters beyond our setup
Any team using Kilo Code seriously — with custom modes, versioned configs, and specialized role definitions — will hit this ceiling:
whenToUsebecomes decorative for orchestrator-driven workflows if the orchestrator doesn't read it.- Custom modes can't fully replace built-ins without workarounds, despite being the intended extension mechanism.
- Customization ceiling: The infrastructure is already there (YAML, lifecycle,
whenToUse) — it just doesn't reach the orchestrator routing layer.
We suspect this affects any user who has invested in custom mode design beyond the basics.
Thanks for the great work on this — looking forward to seeing where Org Modes lands. Terry & Team
I think this is done? I see Code Reviewer coming down in my extension. @TerrysAgentsLab - are you seeing this work as well in recent versions?
Yes — from our side this is resolved now.
The original pain point for us was that the built-in agents were too rigid and couldn't cleanly be replaced in our workflow. With the newer Kilo framework, agent control is much more flexible, and we can now disable the standard agents and replace them with our own custom ones.
That was the key issue for us, so we'd consider this solved. Thanks for following up.
Thanks for confirming! Closing.