Skip to content

feat(core): add Kilo agents - #14999

Merged
marius-kilocode merged 2 commits into
v2from
v2-kilo-agents
Oct 19, 2026
Merged

marius-kilocode merged 2 commits into
v2from
v2-kilo-agents

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

v2 ships only the upstream agents: Build, Plan, and the General and Explore subagents. Kilo v1 ships Code, Ask, Debug, Orchestrator and Plan, with Kilo prompts and permissions. Without them, Shift+Tab shows Build and Plan only, and no read-only Ask agent exists. This is plan unit U-E2-12.

Why This Change Was Made

The agents live in a Kilo-owned built-in plugin, packages/core/src/kilocode/agent.ts, which uses the public agent editor (ctx.agent.transform). The shared changes are small and marked kilocode_change:

  • packages/core/src/plugin/internal.ts: one import and two list entries. KiloAgentPlugin.Plugin runs in pre, after the native agent and Plan plugins. KiloAgentPlugin.Ceiling runs in post, right after ConfigAgentPlugin.
  • packages/server/test/fetch.test.ts: the readiness probe now waits until the config rule shell * ask is the last shell rule. Kilo's own default shell rules also contain * ask, so the old probe passed before config was applied.

Behavior comes from v1 on main (packages/opencode/src/kilocode/agent/index.ts, kilocode/session/mode-reminders.ts). v1 bash and task rules map to v2 shell and subagent.

Agent Change
Code Copy of native build with ID code, as in v1. It is the default agent. The TUI shows the title-cased ID, so it shows "Code" without a TUI patch
build Hidden copy of Code. v1 resolved build to code. Upstream code, tests, commands and clients that still name build keep working, and the list has no second Code entry
Ask v1 prompt (CLI diagram line). Catch-all deny, the v1 read-only shell allowlist and blocklist, read/grep/glob/skill/question/webfetch/websearch, the tool and shell output directories. No edit, no subagents
Debug v1 prompt, Code permissions
Orchestrator v1 prompt ("task tool" is now "subagent tool"). Read-only tools and subagents, no shell, no edit
Plan v1 description and read-only guard: catch-all deny, read-only shell, subagents except general. It keeps the native Plan directory that the native Plan reminder names
Code, Debug, General v1 default shell rules: ask, except the read-only and file housekeeping allowlist
  • The cycle order is the v1 order: Code, Ask, Debug, Orchestrator, Plan.
  • User agents win over built-ins as in v1. A user agent with the same ID merges over the built-in, so its prompt and fields replace the built-in values, its rules match last, and disabled removes it.
  • Read-only limits after config, as in v1 ("Ask" mode edits the codebase #12053). Global config rules cannot open shell, edit, delegation or unknown tools in Ask and Plan, or shell in Orchestrator. Global rules still tune the guard's own tools and keep their denies. Rules configured for one agent by ID come last and stay the v1 opt-in. The ceiling reads the global rules from a hidden probe agent that config fills and the ceiling removes.
  • Agent-switch reminder, as in v1. On each agent switch, the model gets one persisted reminder that names both agents. The capability line says whether the agent may modify files (built-in agents) or tells it to follow its configured permissions (custom agents). A switch to Plan also gets the native Plan reminder, as v1 sent both.

Differences from v1

Area v1 This PR Owner
Ask MCP tools Ask per MCP server Denied by default. agent.ask.permission can allow them Follow-up
Plan edits with a per-agent rule Plan edit guard reapplied after per-agent rules A per-agent rule can widen Plan edits U-E2-13
Plan file location, plan_exit, plan prompt .kilo/plans, Kilo plan prompt and follow-up Native ~/.opencode/plan and native Plan reminder U-E2-13
Explore Read-only shell (28 + 20 allowlist), Kilo prompt Native Explore (all shell commands allowed) U-E2-17
Delegated subagents Plan and Ask denies carry into subagents Each subagent uses its own rules U-E2-17
External directories Ask, with an allowlist of Kilo directories Native allow for Code, Debug and General U-E2-17
agent.build config, default_agent: "build" Map to code Configure the hidden build copy U-E1-07
Ask diagrams in VS Code and JetBrains Mermaid Plain text (CLI variant) G2 client gating
Orchestrator "deprecated" badge, typed displayName and source Present v2 agent schema has no fields for them Later
Agent builder (/agent-builder HTTP API, JetBrains only) Present Not ported. Needs the Kilo RPC scaffolding (U-E0-02) Later PR
Scout Experimental, default off Not ported U-E11-05
Rules for tools v2 does not have yet (memory, board, notebook, semantic search, suggest) Present Each tool unit adds its rules Tool units

User Impact

  • Shift+Tab cycles Code, Ask, Debug, Orchestrator, Plan. The prompt shows "Code" instead of "Build".
  • Ask answers without changing files. It can run read-only commands such as git log.
  • Code asks before shell commands outside the allowlist, as in v1.
  • A global "*": "allow" in config no longer makes Ask or Plan writable.

Shift+Tab cycles the Kilo agents: Code, Ask, Debug, Orchestrator, Plan

The agent dialog lists code, ask, debug, orchestrator and plan

Ask reads math.ts and refuses to edit it

After a switch from Ask, Code asks permission before node -e

Evidence

Automated (temporary XDG directories):

Command Result
bun typecheck in packages/core and packages/server pass
oxlint, prettier --check, ast-grep on changed files pass
bun test test/kilocode (core) 8 pass: agent set and order, shell defaults, Ask read-only, Orchestrator, Plan, user agent override, global config ceiling, switch reminder with the Plan reminder
The ceiling test without KiloAgentPlugin.Ceiling fails (deny expected, allow received), so the test covers the ceiling
Core agent, plan, config agent and command subagent suites 69 pass
Core session runner, title, generate, subagent and shell suites 337 pass, 6 fail. The 6 are the known macOS bash 3.2 cases in pinned-v2-baseline.md
bun test test/fetch.test.ts (server), 3 runs 12 pass each
Full server suite 68 pass, 3 fail locally (download HEAD, 2 plugin clone tests). They do not touch agents and did not fail in CI

TUI self-test (skill recipe, bun dev --standalone with a new profile, kilo/kilo-auto/free, test repo with math.ts):

Scenario Result
Home screen prompt label pass: Code · Auto Free Kilo Gateway
Shift+Tab five times pass: Ask, Debug, Orchestrator, Plan, Code
/agents dialog pass: code, ask, debug, orchestrator, plan. No build
Ask: "Change VERSION in math.ts to "2.0.0". Edit the file now" pass: refused, math.ts unchanged
Ask: run git log --oneline pass: ran without a prompt
Code: run node -e "console.log(41+1)" pass: "Permission required" shown, rejected
Code: run ls pass: ran without a prompt
Switch Code to Ask, then Ask to Code (session database) pass: one reminder per switch, stored before the user message, with the read-only and the writable capability line
Switch Ask to Plan (session database) pass: exactly one native Plan reminder and one Kilo switch reminder
CLI log errors none

The model refused the Ask edits on its prompt. The unit tests cover the rule-level denies (edit, subagent, unknown tools, writes and redirects in shell, global config widening).

The v2 TUI still shows the upstream logo. Branding is a separate unit.

@github-actions github-actions Bot added the area:cli CLI, TUI and core engine label Oct 12, 2026
Comment thread packages/core/src/kilocode/agent.ts Outdated
item.system = PROMPT_ASK
item.mode = "primary"
item.permissions = [
rule("*", "*", "deny"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Ask's read-only permission set can be silently widened by config permissions.

These denies are the last entries in item.permissions, but ConfigAgentPlugin runs later (packages/core/src/plugin/internal.ts:254) and appends global and per-agent config permissions to every agent (packages/core/src/config/plugin/agent.ts:90-92 and :121-123). Permission.evaluate selects with findLast (packages/core/src/permission.ts:91), so a later config rule overrides these denies. A global permissions: [{ action: "edit", resource: "*", effect: "allow" }] therefore lets Ask edit files, and the Plan agent at line 215 has the same exposure. v1 reapplied a read-only ceiling after global rules (#12053); v2 has no seam for that here. Track or document this regression explicitly.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread packages/core/src/kilocode/agent.ts Outdated
item.mode = "primary"
item.permissions = [
rule("*", "*", "deny"),
...["read", "grep", "glob", "question", "skill", "subagent", "webfetch", "websearch"].map((action) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Orchestrator's read permission drops the .env guard that the other Kilo agents keep.

item.permissions is replaced wholesale here, so Agent.Info.default's read *.env -> ask, read *.env.* -> ask, and read *.env.example -> allow rules are discarded and read * -> allow lets Orchestrator read .env files with no approval. Code/Debug inherit the guard from the native Build agent and Ask/Plan include it via the read table. Consider spreading read (or adding the .env rules) into this array for consistency.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

- Use plain-text or ASCII diagrams when they help clarify your response. The CLI cannot render Mermaid diagrams. Only provide Mermaid source when the user explicitly requests it
- You may run read-only bash commands (ls, cat, grep, git log, git diff, etc.) to gather information
- You must NOT modify files, run write commands, or execute code — you are read-only
- MCP tools are available if configured — each call requires user approval

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: This claims MCP tools are available to Ask, but Ask's rules deny them.

MCP tools assert their own action name (packages/core/src/tool/mcp.ts:52), which is not in Ask's allow list, so the rule("*", "*", "deny") at agent.ts:172 denies every MCP call. This matches the PR's own note that "Ask has no MCP access yet". The prompt should not advertise a capability the agent cannot use, since the model may keep attempting MCP tools and fail.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1

The incremental commit adds a post-config Ceiling plugin and an agent-switch reminder. seal() correctly re-applies the Ask/Plan read-only shell, edit, and delegation limits after global config rules, and the reminder matches the documented behavior in the new tests. One consistency gap remains.

Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/core/src/kilocode/agent.ts 306 Orchestrator's read rules omit the read *.env -> ask / read *.env.* -> ask guard that Code/Debug/Ask/Plan keep, so Orchestrator reads .env files with no approval.
Files Reviewed (6 files)
  • packages/core/src/kilocode/agent.ts - 1 issue
  • packages/core/src/kilocode/agent/agent-switch.txt - none
  • packages/core/src/kilocode/agent/ask.txt - none (MCP line removed)
  • packages/core/src/plugin/internal.ts - none
  • packages/core/test/kilocode/agent.test.ts - none
  • packages/server/test/fetch.test.ts - none

Fix these issues in Kilo Cloud

Previous Review Summaries (2 snapshots, latest commit a7587fe)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit a7587fe)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2

The Kilo agent set is faithfully ported: the code/hidden-build split, the Ask/Plan read-only shell allowlist plus defense-in-depth denies, and the Plan re-insertion all match the stated v1 behavior, and the permission ordering (findLast) is used correctly. Re-checking the changed files at the current head found no new defects; the three findings below remain present.

Issue Details (click to expand)

WARNING

File Line Issue
packages/core/src/kilocode/agent.ts 172 Ask (and Plan at line 215) read-only denies can be widened by later config permissions, because ConfigAgentPlugin (packages/core/src/config/plugin/agent.ts:91-92) appends global and per-agent rules after them and Permission.evaluate selects with findLast (packages/core/src/permission.ts:91). A global edit * allow therefore lets Ask edit files.

SUGGESTION

File Line Issue
packages/core/src/kilocode/agent.ts 197 Orchestrator replaces permissions, dropping the read *.env -> ask guard that Code/Debug/Ask/Plan keep, so Orchestrator reads .env with no approval.
packages/core/src/kilocode/agent/ask.txt 11 Prompt advertises MCP tools, but Ask's rules deny every MCP action (also noted in the PR as "Ask has no MCP access yet").
Files Reviewed (6 files)
  • packages/core/src/kilocode/agent.ts - 2 issues
  • packages/core/src/kilocode/agent/ask.txt - 1 issue
  • packages/core/src/kilocode/agent/debug.txt - none
  • packages/core/src/kilocode/agent/orchestrator.txt - none
  • packages/core/src/plugin/internal.ts - none
  • packages/core/test/kilocode/agent.test.ts - none

Fix these issues in Kilo Cloud

Previous review (commit e8e2ef2)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2

The Kilo agent set is faithfully ported: the code/hidden-build split, the Ask/Plan read-only shell allowlist plus defense-in-depth denies, and the Plan re-insertion all match the stated v1 behavior, and the permission ordering (findLast) is used correctly. Findings below are security/consistency gaps in the new rules.

Issue Details (click to expand)

WARNING

File Line Issue
packages/core/src/kilocode/agent.ts 172 Ask (and Plan at line 215) read-only denies can be widened by later config permissions, because ConfigAgentPlugin appends global/per-agent rules after them and Permission.evaluate uses findLast. v1 reapplied a ceiling after global rules (#12053).

SUGGESTION

File Line Issue
packages/core/src/kilocode/agent.ts 197 Orchestrator replaces permissions, dropping the read *.env -> ask guard that Code/Debug/Ask/Plan keep, so Orchestrator reads .env with no approval.
packages/core/src/kilocode/agent/ask.txt 11 Prompt advertises MCP tools, but Ask's rules deny every MCP action (also noted in the PR as "Ask has no MCP access yet").
Files Reviewed (6 files)
  • packages/core/src/kilocode/agent.ts - 2 issues
  • packages/core/src/kilocode/agent/ask.txt - 1 issue
  • packages/core/src/kilocode/agent/debug.txt - none
  • packages/core/src/kilocode/agent/orchestrator.txt - none
  • packages/core/src/plugin/internal.ts - none
  • packages/core/test/kilocode/agent.test.ts - none

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 126.8K · Output: 49.9K · Cached: 2.5M

@WebReflection

Copy link
Copy Markdown
Contributor

AI counter-check findings

  • packages/server/test/fetch.test.ts "routes pending requests through the Session's instance" is deterministically broken by this change (CI red on both unit (linux) and unit (windows)). The new KiloAgentPlugin is registered at boot (packages/core/src/plugin/internal.ts:322) and gives the build/code default agent "pwd *": "allow" (packages/core/src/kilocode/agent.ts:39). The server test boots the full app, then POSTs a pending permission { action: "shell", resources: ["pwd"] } and asserts the response is { data: { id: "per_pending_read", effect: "ask" } } — it now receives "effect": "allow" (fetch.test.ts:577-583). The failure is not flaky: the base branch (v2-migration-skill) passed test at 11:55/13:05/13:07 today, and the other branch failure (gateway-login) was a different, timing-flaky test. The PR's own core tests pass (328 tests, 0 fail), but the server-package expectation of the native default agent was not reconciled with the new Kilo shell rules, leaving the pipeline failing.

Base automatically changed from v2-migration-skill to kilo-v2-clean-bootstrap October 13, 2026 04:05
@marius-kilocode
marius-kilocode changed the base branch from kilo-v2-clean-bootstrap to v2 October 13, 2026 08:39
],
orchestrator: [
rule("*", "*", "deny"),
...allow("read", "grep", "glob", "question", "skill", "subagent", "webfetch", "websearch"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Orchestrator's read rules drop the .env guard the other Kilo agents keep.

guards() gives Orchestrator read * -> allow with no read *.env -> ask / read *.env.* -> ask rule, so replacing its permissions with structuredClone(guard.orchestrator) leaves Orchestrator able to read .env files without approval. Code/Debug inherit the guard from the native Build agent, and Ask/Plan include it via the read table. Consider spreading the read table (or adding the .env rules) here for consistency.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@marius-kilocode
marius-kilocode merged commit 2a28de2 into v2 Oct 19, 2026
11 checks passed
@marius-kilocode
marius-kilocode deleted the v2-kilo-agents branch October 19, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli CLI, TUI and core engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants