Repository navigation
Conversation
Code Review sessions let the Kilo CLI choose title and auxiliary models. The CLI fell through to `kilo-auto/small`, which resolves to Gemma on Kilo credits. This happened even when the user set a BYOK review model. See issue Kilo-Org#4268. Resolve a cheap model from the same vendor as the effective review model. Use the OpenRouter catalog prices for managed vendors. Use the BYOK primary model for direct-BYOK vendors when the catalog has no cheaper sibling. Leave `small_model` unset when no cheaper managed sibling exists. Thread the value from apps/web dispatch to the sandbox session config. Persist it in the v2 session metadata. Include it in the create-intent fingerprint. Add `small_model` and `agent.title.model` to the sandbox KILO_CONFIG for code-review sessions only. Do not inject `agent.title` for Bitbucket sessions. Tests cover the resolver, payload plumbing, session materialization, the metadata round trip, and the Durable Object registration boundary.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (19 files)
Reviewed by grok-4.6 · Input: 123K · Output: 14K · Cached: 573.2K Review guidance: REVIEW.md from base branch |
…k-small-model Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
…k-small-model Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
|
Hey @maphew I think the small-model choice belongs in the CLI as it already resolves the small model per request in CLI should have access to the model list as well so that we can pick a cheaper same-vendor model by price, could you take a look if we can fix it there for everyone? |
|
Good question — I agree the unconditional kilo-auto/small fallback in getSmallModel is the real root cause, and fixing it in the CLI would cover titles, prompt-enhance, commit messages and branch names for everyone, not just code review. This PR stays web-side deliberately as the narrow fix for #4268: the web dispatcher already knows the effective review model and the vendor catalog at dispatch time, so it can pin small_model per review session today with no CLI release coordination and no behavior change to the other aux-call paths. A CLI-side fix (vendor-aware fallback, or at least a Kilo-billed check before falling through to kilo-auto/small) is the right follow-up and would subsume this — happy to open that issue against Kilo-Org/kilocode and link it here, or close this in favor of it if you prefer the CLI fix first. Which do you want? |
|
@maphew because something similar already exists in the CLI, I think it should be there to avoid spreading similar logic in different places. It may be useful in the end for more than just a code reviewer. |
|
@eshurakov Agreed — done: the CLI-side fix is up as Kilo-Org/kilocode#14263. |
Refs #4268.
Problem
A user set a BYOK model for Code Reviewer. The review itself used that model.
But Kilo credits still went down. The Kilo CLI used a separate small model for
title and auxiliary calls. The CLI fell through to
kilo-auto/small. Thatresolves to
google/gemma-4-26b-a4b-it. The Gemma call goes through Kilo, notthe user provider.
Change
The web dispatcher now picks a cheaper model from the same vendor as the
effective review model. It uses the OpenRouter catalog and prompt prices.
the catalog has no cheaper BYOK sibling. This keeps the call on the user key.
small_modelunset. The CLIkeeps its current default in that case.
The value travels as
smallModelfromapps/webto the sandbox sessionconfig. It is stored in the v2 session metadata. It is part of the create
intent fingerprint. The sandbox
KILO_CONFIG_CONTENTgetssmall_modelandagent.title.model. This applies to code-review sessions only. Bitbucketsessions do not get
agent.title.Relation to other work
inactivity. This PR takes over that design.
areThreadsBlocking()to use a BYOK model. Thatpath uses Cloudflare Workers AI, not the Kilo gateway. It does not draw Kilo
credits. This PR does not change gastown. The hardcoded Gemma id in gastown
stays as a separate, smaller follow-up.
Adversarial review
An independent review agent examined the diff against main. It found one
critical defect in the first revision. The Durable Object rebuilt
metadata.agentfrom a fixed field list. It droppedsmallModel, so the fixwas inert. The fix now writes
smallModelinregisterSessionand in theadmitted-plan agent. A new Durable Object integration test asserts the
persisted value. A second review pass confirmed that all findings are closed.
Verification
Passed:
pnpm run typecheckinapps/web,services/cloud-agent-next,services/code-review-infra, andpackages/worker-utils.oxlintandoxfmt --list-differenton all changed files.vitest runinservices/cloud-agent-nextforsession-service.test.ts,session/session-prepare.test.ts,persistence/session-metadata.test.ts,and
router/handlers/session-worktree.test.ts: 453 tests pass.vitest run --config vitest.workers.config.tsfortest/integration/session/code-review-small-model.test.tsandtest/integration/session/start-execution-v2.test.ts: 41 tests pass.Not run locally:
apps/webjest tests (model-selection.test.ts,prepare-review-payload.test.ts). The jest global setup needs a livePostgreSQL test database. The sandbox has no Docker and no database. CI
covers these tests.