Repository navigation
feat(kilocode): run Kilo in task sandboxes - #4305
Merged
Merged
Conversation
Add native sandbox sessions to the KiloCode agent so it composes with any Resources server through single_agent_turn_legacy, as Pi and Codex do. - Session setup installs a checksum-verified Node 22 and the pinned @kilocode/cli into a private per-session directory (glibc and musl); task images need only Linux and Python 3.8+. - The CLI runs under the shared SandboxSession supervisor in the task workdir with isolated HOME/config/database and no repo-level config. - Close returns observations from a snapshot of Kilo's SQLite database (root and child sessions, tool timing, usage), annotated with the run outcome; CLI/API errors fail the episode instead of scoring zero. - Kilo's stream watchdog (chunkTimeout) follows the harness timeout, since the Gym model server returns completions only once finished. - Host installation becomes lazy, on the first local invocation. - kilocode_sandboxed.yaml, SWE-bench Pro allowed_agents, and the legacy environment-server migration entry. Validated on SWE-bench Pro with the stock Resources server: 5-task smoke across Ubuntu/Node/Go/Python/Alpine images, and 731x3 at 51.30% mean pass@1 (Nemotron 3.5 Super). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Marat Kitov <[email protected]>
Keep the sections other native harnesses document; move run results and limitations to the PR description. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Marat Kitov <[email protected]>
yaoyu-33
reviewed
Oct 9, 2026
Signed-off-by: Marat Kitov <[email protected]>
Address review and match Pi, Codex, OpenCode and OpenClaw. - Classify a run from the supervisor cleanup receipt. A runner exit, supervision error or missing exit status without a timeout fails the episode instead of returning an empty incomplete response. Supervised timeouts and length stops stay gradable. - Run a POSIX sh bootstrap before the Bash installer, and check in the sandbox that the task workdir and session storage do not overlap after resolving symlinks. - Return 422 for unsupported setup, require direct SandboxAccess, and return 409 for activation of a closing session or /run with a session. - Snapshot the Kilo database only after confirmed cleanup, and report a gap when the receipt has no exit code. - Add bootstrap, lifecycle-contract and exec-transport tests from the reference harness templates. Validated on 250 SWE-bench Pro tasks with the stock Resources server: 250/250 graded, no agent or infrastructure failures. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Marat Kitov <[email protected]>
Contributor
Author
|
Thanks @yaoyu-33, this time I explicitly checked test cases of the other sandboxes. I aligned dependency bootstrapping, runtime error propagation, and additionally HTTP error handling to match them. |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Marat Kitov <[email protected]>
Sandbox sessions: - A run that times out before any model call completed (for example an unreachable model server) now fails instead of being graded as a zero; the error carries the tail of Kilo's log, which names the cause. - A retried close no longer cancels an activation that is already cancelling. - The runner records its hostname and PID; responses report them with the Kilo version, and the sandbox record carries the sandbox id. Local runs: - Output is file-backed and the process group is killed on timeout and on request cancellation, so partial events survive and Kilo never outlives its request. - CLI errors, nonzero exits and timeouts before any model call return a failed response with the reason; /run reads Kilo's session database and returns agent observations. Shared: - Use opencode_agent's session parser (maps bash outcomes from exit codes) instead of the deprecated opencode_sandboxed_agent. - Disable Kilo's auxiliary session-title call by default for Gym-managed providers. - Register Kilo in the harness conformance suite; rename setup_kilo to setup_kilocode to follow the setup_<harness> convention. - Add a read-only AsyncSandbox.sandbox_id property. Conformance (session mode, Linux): all checks pass in 6 of 7 scenarios; model_error shows the session-mode gap shared by all harnesses (#4489). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Marat Kitov <[email protected]>
yaoyu-33
reviewed
Oct 14, 2026
…state Kilo's tool shells inherited the HOME and XDG directories that keep Kilo's own state private, so files that tools wrote under the home directory landed in the session directory and were deleted by agent close before verification. A plugin now restores the task's HOME and XDG directories for every shell command through Kilo's shell.env hook, as OpenCode does. Sandbox runs no longer pass --pure, which would skip that plugin; codebase indexing stays off because kilo.json names no indexing plugin. Kilo only logs a plugin that fails to load, so a run without the plugin's receipt fails instead of being verified. Also from review: - A cancelled local caller no longer releases another caller to start a second installer; one shielded installation task is shared, as in Pi. - An owned sandbox is retained in the session before start(), so close can stop a sandbox that start() allocated but failed to finish setting up. - A child invocation that stopped on the output limit is reported as incomplete, not completed (require_terminal_finish=True). Validation: Kilo tests pass locally, including the plugin loaded by the pinned Kilo 7.4.15 binary; the Linux unit suite on AGA shows no new failures; a 5-task SWE-bench Pro smoke returned and graded 5/5 (4 solved), with the plugin confirmed in every run and no tool output referring to Kilo's private home. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Marat Kitov <[email protected]>
…docs Conformance CI install looked up kilocode_version, but Kilo's configs only define kilo_version, so setup raised KeyError for the newly registered harness. Map kilocode to kilo_version. The README claimed musl support on aarch64, but install_kilo_runtime.sh rejects it (the pinned Node musl build is x86_64 only). Document that. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Resolve the harness registry conflict by keeping both kilocode and stirrup. Main made a negative cleanup receipt final for borrowed sandbox sessions: close now releases the session for Resources teardown instead of staying retryable. Update the KiloCode lifecycle test to match, as main did for OpenCode. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
|
/ok to test 2f09341 |
…mantics Main now leaves detached tools from a natural CLI exit for the sandbox owner to tear down, and treats a negative cleanup receipt as final: close releases the borrowed session instead of staying retryable. Update the KiloCode exec transport tests to match, as main did for Codex and OpenCode. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
|
/ok to test 32983a5 |
yaoyu-33
enabled auto-merge
October 20, 2026 21:15
yaoyu-33
approved these changes
Oct 20, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/39499174630 |
yaoyu-33
added a commit
to yaoyu-33/Gym
that referenced
this pull request
Oct 21, 2026
Resolves one conflict in `resources_servers/swebench_pro/configs/swebench_pro.yaml`. NVIDIA-NeMo#4305 added `kilocode_agent` to SWE-Pro's `allowed_agents` while this branch removed `hermes_sandboxed_agent` from it; the resolution keeps both changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
This PR adds native task-sandbox sessions to the KiloCode agent. The design is the same as Pi (#3626) and Codex (#3640). Kilo runs inside the task sandbox that the Resources server supplies.