git clone, install dependencies, and execute the
CLI in isolation from the API process.
The same sandbox gives review agents their file tools (search, read file,
list directory) over the checked-out repository, in reviews and in @kody
conversations.
This page explains the sandbox modes you can pick from, what the AST
graph is, and how the cache keeps PR-level reviews fast.
How the AST graph works
Kodus uses@kodus/kodus-graph,
a CLI that walks a repository and emits a JSON graph (functions, classes,
files, imports, calls). The CLI is pre-installed in the Kodus images
(including kodus-ai-worker), so there is no extra setup step on local mode.
The lifecycle:
- When you select a repository (during setup, or when adding a repo
later in the UI) — Kodus enqueues an
AstGraphBuildjob that runskodus-graph parse --allagainst the default branch, persists the result to Postgres (ast_graph_*tables), and marks the repo as indexed. This happens in the background — you don’t have to wait for it to finish before opening PRs. - When a PR is merged into the default branch — webhook handlers enqueue an incremental rebuild that re-parses only the changed files and merges the deltas into the cached graph. A merge that changes more than 500 files triggers a full rebuild instead.
- On every PR review — Kodus loads the cached graph, parses only the files touched by the PR, and feeds the agent a focused subgraph. This is the hot path; it never re-parses the whole repo.
Sandbox modes
The sandbox is selected bySANDBOX_PROVIDER in .env:
Picking a mode
- You’re getting started, want it to “just work” →
local. This is the installer default and needs zero external accounts. - Repos are very large or you want strict isolation →
e2b. Sign up at e2b.dev, setAPI_E2B_KEY, switchSANDBOX_PROVIDER=e2b.
SANDBOX_PROVIDER=e2b without API_E2B_KEY leaves reviews with no sandbox:
no cross-file context, and no code graph. Setting only API_E2B_KEY while
SANDBOX_PROVIDER=local keeps the local sandbox.
Set SANDBOX_PROVIDER=null to turn the sandbox off. ./scripts/doctor.sh warns when it is off. If ./scripts/validate-env.sh rejects null, check the allowed values in the installer’s .env.example. Older installer schemas list none, which the worker treats as auto.
Migrating an existing self-hosted install
If you upgraded from a release that predates the AST graph, your already-selected repositories won’t have a graph yet — the build only fires automatically on new repo selections. To index them, run the backfill script bundled with the installer:AstGraphBuild
job for each selected repo whose graph status is not set, pending or
failed. Builds run in the background — you can keep using Kodus
while they finish.
The script is idempotent: re-running skips repos that are already
ready, never re-enqueues building jobs, and you can stop and resume
freely.
Common flags:
Configuration
.env and run ./scripts/install.sh again.
In local mode the worker clones the repository with a 120 second budget. A
slow clone of a very large monorepo can exceed it, and the review then runs
without a sandbox. Raise the budget in milliseconds:
What runs where
Resource sizing
Thelocal sandbox runs git clone and kodus-graph parse inside the
worker container, so the worker’s memory limit applies to them. The Helm
chart sets a 1536Mi limit on the worker. If the worker is killed for memory
while it builds a graph, raise the limit under services.worker.resources, or
use e2b to parse off the host.
Troubleshooting
Reviews don’t include cross-file context (local mode):
Check the worker logs for clone or kodus-graph parse errors:
./scripts/doctor.sh runs a read-only
git ls-remote against a selected repository and reports a failure.
e2b jobs hang or fail to start:
Verify API_E2B_KEY is set and valid: