kilo_implement
Delegate a concrete code implementation task to Kilo and get a task_id immediately, so you stay the architect while Kilo edits files and runs commands.
Instructions
Delegate a concrete code IMPLEMENTATION task to Kilo (the executor) while you stay the architect/orchestrator/reviewer.
⚠️ SIDE EFFECTS: Kilo runs non-interactively and AUTO-APPROVES its actions —
it will create/edit/delete files and run commands in working_directory
without asking. Only delegate work you have specified precisely, in a
version-controlled directory, and review the diff afterwards.
NON-BLOCKING BY DEFAULT: this tool starts the task and returns IMMEDIATELY
with a task_id — it does NOT wait for Kilo to finish, so the calling
conversation is never blocked on a long-running delegation. Use:
kilo_task_progress — live plan/todo list, recent commentary, cost so far.
kilo_task_status — quick OS-level heuristic (any
kilo runprocess).kilo_task_result — the final report, once it is done.
kilo_task_cancel — stop it if it is going wrong. Pass
background=falseonly for short tasks where you deliberately want to block and get the full report back in this same call.
How to use it well:
(Optional) kilo_rag_search to locate the relevant files.
Write a precise spec in
task_instructionsor pass an existing Markdown file viabrief_file(when both are given,task_instructionsis appended under## Additional instructionswithout modifyingbrief_fileon disk); pass the key files asfocus_files; addexecution_hints,skills_to_load, and optionallylog_dir(to also save<task_id>.login the project; relativebrief_file/log_dirpaths resolve against the originalworking_directoryeven withisolation='worktree'). When the task instructions enumerate items (a numbered or bulleted list of deliverables), Kilo is instructed to include one line per item ("done" or "not done: why") in the Final Report, in the same order. Initial context size (prompt + focus_files) is checked by preflight: warns abovemax_context_tokens_warn(default 40,000) and refuses abovemax_context_tokens_refuse(default 120,000; 0 disables) to avoid connection resets.Pick a valid
model(see kilo_list_models) andagent.Scale how closely you watch it to the task's complexity/risk: a small, well-scoped change needs only a final kilo_task_result check; a large, multi-file, or high-risk delegation deserves periodic kilo_task_progress polling so you can catch it drifting off-spec early.
Act as reviewer: check
Exit Codeand review the Final Report and changed files; inspect the resulting changes.
STEERING & RESUMING: if a run (background or foreground) drifts off-spec, don't just
restart from scratch — read its session_id (in the result / progress
report), optionally kilo_task_cancel the current run, then call
kilo_implement again with continue_session_id set to that id and corrective
task_instructions. Kilo resumes the SAME session with full memory of what
it already built, rather than starting blind. If a run died mid-way (network
error, cancel, crash, or failed_with_uncommitted_work), pass resume_task_id
set to the previous task id: kilo_implement reuses its worktree and branch
(refusing if the worktree is gone or another run is active on it), reuses its
Kilo session when known (else starts a fresh session), prepends a generated
preamble with git status --short, git diff --stat, commits since base, and
resume instructions to the original spec stored in the task record (with
optional task_instructions appended as corrections), and links
resumed_from: <old id> on the new task record. If a task is still actively
running on that session or worktree, kilo_implement refuses to spawn a second
process — wait for it to complete with kilo_task_wait or stop it with
kilo_task_cancel before continuing. When continuing or resuming in an isolated
worktree, pass refresh_base='merge' or refresh_base='rebase' to update the
worktree from the current tip of its base branch before resuming; when
conflicts occur, refresh_base_on_conflict='abort' (default) aborts and returns
the conflicting files, while refresh_base_on_conflict='resolve' (with
refresh_base='merge' only; rebase + resolve is refused) leaves the
conflicted merge in place and instructs Kilo in the prompt to resolve the
conflicts preserving both sides' intent, run the tests, and complete the merge
commit before continuing.
Parallelism & Batch Queues: emitting several kilo_implement calls in one turn
runs them concurrently (independent Kilo subprocesses). For large batches, pass
queue='<name>' (with background=true) and optional queue_concurrency=<int>
to enqueue runs in FIFO order instead of spawning all at once. A detached queue
runner (python server.py --queue-runner) starts queued tasks while slots are
free under both the queue's cap and the global max_concurrent_runs cap
(config [kilo].max_concurrent_runs / env KILO_MCP_MAX_CONCURRENT_RUNS,
default 3), so the queue keeps draining even after the calling session and MCP
server process exit.
⚠️ NO ISOLATION, NO LOCKING BY DEFAULT: Kilo runs directly in
working_directory with nothing preventing a concurrent writer — another
kilo_implement call, or your own git commands — from racing it in the same
tree (uncommitted changes lost, branches reset out from under a run,
whichever writer runs last silently wins). Pass isolation='worktree' to
auto-create a dedicated git worktree + branch for this run (equivalent to
calling kilo_create_worktree yourself first) — use it for anything beyond a
single trivial edit, and always when dispatching parallel tasks against the
same repo. If you don't isolate, the response is prefixed with a collision
warning whenever another task is already running against the exact same
working_directory — treat that warning as a stop sign, not a formality.
When to skip a worktree: a worktree adds nothing for a brand new repository or a directory nobody else writes to; it is still recommended whenever another writer (a session, the user, another task) may touch the same tree.
⚠️ PROTECTED CONFIG FILES: Kilo always asks for approval before editing the
project-root AGENTS.md, kilo.json(c), opencode.json(c), or anything
under .kilo/ or .kilocode/ (except .kilo/plans/), whatever the
permissions say. A non-interactive run auto-rejects that ask and ENDS, with
no Final Report and no commit. The delegated prompt therefore tells Kilo to
write the intended content to <path>.proposed instead; apply it yourself.
Don't ask Kilo to edit those files directly.
⚠️ EXTERNAL PATHS: Unattended runs cannot read outside the working directory unless
the Kilo config allows external_directory; do real-world checks on such paths on
the orchestrator side.
Handling of *.proposed files is controlled by proposed_files:
proposed_files='untracked'(default): Kilo is instructed to leave*.proposedfiles uncommitted (nevergit addthem, committing everything else). After the run, kilo-mcp lists any*.proposedfiles present in the working tree in the result ("Proposed files to apply: …"). If one got committed anyway, the result says so explicitly.proposed_files='commit': Kilo is allowed to commit*.proposedfiles alongside other changes as before.
Returns a text report (trimmed by default: status, exit code, session_id,
worktree/branch when present, parsed Final Report, and log file path; pass
include_trace=true for the full run trace).
When to delegate
Kilo runs at no cost to this operator; the only cost is your own (Claude) tokens. DELEGATE to Kilo when doing the task yourself would need a large agentic loop that is specifiable up front — multi-file changes, bulk/mechanical generation (e.g. tests for every endpoint), wide refactors, anything where the resent context of an inline loop would dwarf a written spec. ALSO PREFER DELEGATING when Kilo has a skill or agent matching the task's domain (check kilo_list_skills / kilo_list_agents; pass them via skills_to_load / agent): domain-specific skills and agents encode proven procedures and pitfalls, making Kilo's output better than an unguided inline attempt regardless of size. DO IT YOURSELF when the task is small (one or a few files, short edits), needs tight back-and-forth reasoning that can't be pinned down in a spec, or when writing the spec plus reviewing Kilo's output would cost more tokens than just doing it inline. Either way, always review the returned report.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "kilo_implement"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent | No | Kilo agent to use. `code` for implementation (default). Use kilo_list_agents to see custom agents. Note: subagents such as `explore` cannot be used as primary agents for implementation. | code |
| model | No | Model id in `provider/model` form. MUST be a real id from kilo_list_models; an unknown id makes the run fail. Allowed models by policy: google/gemini-3.8-flash (routine tasks) and google/gemini-4-argon (complex/high-risk tasks). This environment has two configured tiers — pick by task risk, don't just reuse whatever model you (the connected assistant) happen to be: simple/routine tasks (mechanical edits, low risk) -> google/gemini-3.8-flash; complex/high-risk tasks (subtle bugs, read-modify-write races, security-sensitive edits, multi-step reasoning) -> google/gemini-4-argon. Defaults to the workspace's configured Kilo model when there is one, or google/gemini-3.8-flash. Run `kilo-mcp --configure-models` to change these tiers, or kilo_list_models for the full catalog. | |
| queue | No | Queue name to enqueue this background run into instead of spawning immediately (e.g. 'audit-batch'; pass 'default' for the default queue). Requires `background=true`. A detached queue-runner process (`python server.py --queue-runner`) starts queued tasks in FIFO order respecting both the per-queue concurrency cap (`queue_concurrency`) and the global `max_concurrent_runs` cap (default 3). Because the queue state and runner live on disk/OS outside the calling session and MCP server process, the queue keeps draining even after both exit. | |
| log_dir | No | Directory (absolute, or relative to `working_directory`; created if missing) where the run log is ALSO written as `<task_id>.log` (tee: the canonical log under the kilo-mcp data dir stays where it is, so kilo_task_result/progress/wait keep working unchanged). With `isolation='worktree'`, relative paths resolve against the original `working_directory` (the main checkout), not the new worktree, so the log lands in the requester's tree. | |
| env_vars | No | Extra environment variables for the Kilo subprocess (e.g. {'DEBUG': '1'}). Powerful and rarely needed; can override Kilo's runtime config. Leave empty unless debugging. | |
| isolation | No | Set to 'worktree' to isolate this run: auto-creates a new git worktree + branch under working_directory (equivalent to calling kilo_create_worktree yourself first, then passing its path as working_directory — but one step, harder to forget) and runs Kilo there instead of directly in working_directory. kilo_implement has NO isolation and NO locking by default: nothing stops a second concurrent call (or your own git commands) from racing this one in the same directory. Use isolation='worktree' for anything beyond a single trivial edit, and always when dispatching multiple kilo_implement calls in parallel against the same repo. Leave unset to run directly in working_directory (you'll get a warning if another task is already running there — see the tool description). The worktree (and later the session, once known) are also registered in .kilo/agent-manager.json best-effort, so they can show up in the Kilo Agent Manager UI — but there is no live sync with a running VS Code extension window: if it's open on this repo, its own next save can silently overwrite this registration with its own in-memory state. Reliable when the extension isn't running against this repo, or visible after its next reload otherwise. | |
| background | No | Default true: start the task and return IMMEDIATELY with a task_id instead of blocking the conversation until Kilo finishes. Monitor with kilo_task_progress (live plan/commentary) or kilo_task_status (quick heuristic); fetch the outcome with kilo_task_result; stop it with kilo_task_cancel. Set to false only for short tasks where blocking for the full report in this same call is actually preferable. | |
| brief_file | No | Path (absolute, or relative to `working_directory`) of a Markdown file used as the task specification. When given, its content is the spec (if `task_instructions` is also non-empty, it is appended after the file content under a `## Additional instructions` heading). Contract sections (executor contract, Final Report requirements, proposed-files rules) are added to the prompt at run time as usual; the brief file itself is never modified. With `isolation='worktree'`, relative paths resolve against the original `working_directory` (the main checkout), not the new worktree, so the brief lives in the requester's tree. | |
| focus_files | No | Paths (absolute, or relative to working_directory) that Kilo must read before making changes. Populate this with the files you identified via kilo_rag_search to keep Kilo focused. Preflight checks initial context size (prompt + focus_files) against configurable warn/refuse thresholds to avoid connection resets. | |
| refresh_base | No | When continuing a session or resuming a task in a worktree (via continue_session_id or resume_task_id), optionally update the worktree from the current tip of the base branch before resuming: 'no' (default, leave worktree as is), 'merge' (git merge <base_branch>), or 'rebase' (git rebase <base_branch>). Conflict behavior is controlled by `refresh_base_on_conflict`. | no |
| include_trace | No | If True, includes the full execution trace in the result. Defaults to False (returns status, exit code, session_id, worktree/branch when present, Final Report, and log path). | |
| proposed_files | No | How to handle `*.proposed` files written when Kilo needs to modify protected config files (AGENTS.md, kilo.json(c), etc.): 'untracked' (default, tells Kilo to leave them uncommitted and lists any in the working tree after the run for the orchestrator to apply) or 'commit' (allow Kilo to commit `*.proposed` files alongside other changes as before). | untracked |
| resume_task_id | No | Task id of a previous interrupted, failed, or cancelled run to resume in the same worktree and branch. Reuses its worktree and branch (refuses with a clear error if the worktree is gone or another run is active on it), reuses its Kilo session when known (else starts a fresh session), and prepends a generated preamble (current `git status --short`, `git diff --stat`, commits since base, and fixed resume instructions) to the original spec stored in the task record. Optional `task_instructions` are appended as corrections. The new task record links `resumed_from: <old id>`. | |
| skills_to_load | No | Names of Kilo skills (from kilo_list_skills) that Kilo should apply to this task. Only listed names have any effect. | |
| execution_hints | No | Strategic guidance on HOW to execute: ordering, constraints, patterns to follow, things to avoid, how to verify. | |
| worktree_branch | No | Branch name for the new worktree when isolation='worktree'. Defaults to 'kilo/<task_id>' if omitted. Ignored unless isolation is set. | |
| queue_concurrency | No | Concurrency cap for `queue` (stored in `<data_dir>/queues/<name>.json`; last value given wins). A queue's runs count against both `queue_concurrency` and the global `max_concurrent_runs` cap. | |
| task_instructions | No | Detailed, self-contained Markdown specification of the work to perform. Required unless `brief_file` is provided; when both `brief_file` and `task_instructions` are non-empty, `task_instructions` is appended after the brief file's content under a `## Additional instructions` heading. YOU are the architect: state goals, constraints, acceptance criteria and edge cases explicitly — Kilo executes what is written and does not share your conversation context. Long specs are fine; they are passed via a temp-file bridge, not the shell. | |
| working_directory | No | Absolute path to the repository/workspace Kilo should run in and modify. Defaults to the server's current working directory. Ensure it is under version control before delegating. Unattended runs cannot read outside the working directory unless the Kilo config allows `external_directory`; do real-world checks on such paths on the orchestrator side. | |
| continue_session_id | No | Kilo session id to resume instead of starting fresh (see the session_id surfaced by kilo_task_progress / a prior kilo_implement result). Use this to STEER a delegation: after reviewing or cancelling a run that went off track, send corrective task_instructions into the SAME session so Kilo keeps the context of what it already built. Leave empty for a fresh session. | |
| worktree_base_branch | No | Base branch/commit for the new worktree when isolation='worktree'. Defaults to the current branch (git worktree add's own default). Ignored unless isolation is set. | |
| refresh_base_on_conflict | No | How to handle conflicts when `refresh_base` ('merge' or 'rebase') encounters conflicts: 'abort' (default, aborts the merge/rebase leaving the worktree untouched and returns an error listing conflicting files) or 'resolve' (supported with refresh_base='merge' only; leaves the conflicted merge in place and adds the conflicting file list and instructions to the prompt so Kilo resolves them preserving both sides' intent, runs tests, and completes the merge commit before continuing; rebase + resolve is refused). | abort |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |