fix(code-review): use configured model for title/aux calls (BYOK) - #4725
fix(code-review): use configured model for title/aux calls (BYOK)#4725baanish wants to merge 4 commits into
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe follow-up commit wires Files Reviewed (2 files)
Previous Review Summaries (3 snapshots, latest commit 5085bb9)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 5085bb9)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe new Overview
Issue Details (click to expand)WARNING
Files Reviewed (13 files)
Fix these issues in Kilo Cloud Previous review (commit f21a13e)Status: No Issues Found | Recommendation: Merge Executive SummaryReviewed the code-review-session model-pinning fix in Files Reviewed (2 files)
Previous review (commit 8aa1cc7)Status: No Issues Found | Recommendation: Merge Executive SummaryReviewed the code-review-session model-pinning fix in Files Reviewed (2 files)
Reviewed by claude-sonnet-5 · Input: 32 · Output: 6.5K · Cached: 719K Review guidance: REVIEW.md from base branch |
|
Thanks for digging into this — the revised diagnosis in your PR body is correct, and it's worth recording the confirmation here since it contradicts the original theory in #4268. The chain checks out end to end:
So Gemma under Code Reviews is the small-model fallback, not gastown's Workers AI call. The mechanism you used is also correct: The one change we'd like before mergingThe gate is The intent behind Our preference for where that lives, which keeps most of your diff intact:
If you'd rather keep this contained to Smaller items
Happy to take this over if you'd rather not carry it further — let us know. |
Code Review sessions only set KILO_CONFIG.model, so kilo's title/aux calls fell through to kilo-auto/small → Gemma and billed Kilo credits even when the primary review model was BYOK. Pin small_model and the title agent to the configured review model for code-review sessions. Fixes Kilo-Org#4268
Always set the title agent model to the configured review model for code-review sessions, even when a runtime agent named title was already merged. Preserve other title-agent options.
Prefer a cheaper same-vendor catalog model for Code Reviewer title/aux calls instead of pinning to the primary review model. Fall back to the primary for sole-model direct BYOK so Gemma does not bill Kilo credits. Leave small_model unset when no cheap sibling exists for managed vendors. Refs Kilo-Org#4268
| // through to kilo-auto/small → Gemma. See https://github.com/Kilo-Org/cloud/issues/4268 | ||
| const normalizedSmallModel = | ||
| smallModel && smallModel.trim() ? normalizeKilocodeModel(smallModel) : undefined; | ||
| if (createdOnPlatform === 'code-review' && normalizedSmallModel) { |
There was a problem hiding this comment.
WARNING: smallModel is not forwarded on the prepareWorkspace session-creation path, so this branch never fires there
The new smallModel parameter is threaded into buildRuntimeEnv/getSaferEnvVars only via buildWrapperSessionReadyAndPromptRequests (smallModel: metadata.agent?.smallModel ?? agent.smallModel). It is not forwarded by getOrCreateSession (destructures opts without smallModel and omits it from the object literal passed to buildRuntimeEnv), nor by buildSessionForContext/prepareWorkspace (neither accepts nor passes smallModel at all). For any code-review session created via prepareWorkspace → buildSessionForContext → getOrCreateSession, smallModel is always undefined, so normalizedSmallModel here is always undefined and configContent.small_model is never set — silently reverting that path to the pre-fix kilo-auto/small → Gemma billing behavior this PR is meant to eliminate.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
getOrCreateSession and prepareWorkspace accepted smallModel on types but never passed metadata.agent.smallModel into buildRuntimeEnv, so KILO_CONFIG.small_model stayed unset on that session-creation path.
Summary
KILO_CONFIG.model, so kilo's title/aux calls fell through to the CLI default (kilo-auto/small→google/gemma-4-26b-a4b-it) and billed Kilo credits even when the primary review model was BYOK.createdOnPlatform === 'code-review', pinsmall_modeland thetitleagent to the same configured review model.Fixes #4268
Note on root cause
Issue #4268 attributed Gemma usage under Code Reviews to gastown's Workers AI
areThreadsBlocking()call. That path does use hardcoded Gemma, but it does not go through the AI gateway and would not appear as gateway Code Reviews usage (especially not with Vercel-style versioned model ids / multi-million-token volume). The Usage dashboard symptom matches kilo's title/aux model defaulting tokilo-auto/smallduring Code Reviewer sessions.Test plan
small_model+agent.title.modelequal to the configured review modelsmall_modelSummary by CodeRabbit