Repository navigation
fix: isolate CodeBuddy model discovery per account - #1179
Conversation
crispinhu27
left a comment
There was a problem hiding this comment.
Automated CR — initial review of head 8293c66 (merge-base 42541ef; also checked against current main 1584230)
Scope: the full diff, 24 files in internal/httpapi, plus the unchanged callers of the model discovery and validation helpers: chat/executor/guest pickers, Bot sender checks, scheduled-job saved models, reports, run-eval, clarify, shared-key allowlist, and cache keying and locking in cachedCLIModels.
Verification (isolated user, no credentials, synthetic data):
go build ./...andgo vet ./internal/httpapi/pass on the PR head, on the PR merged with7dcf3fc, and on the PR merged with1584230. Both merges are clean.go test ./internal/httpapi/: 1230 tests. The only failures are 2 Chromium-dependent tests, which fail the same way on main.- Merged with
7dcf3fc:go test ./internal/httpapi/ ./internal/runtime/fails exactly the same 16 Docker/Chromium/bwrap environment tests as main7dcf3fcand nothing else. - Merged with
1584230: the model, catalog, sponsor, picker, executor, Bot, clarify, schedule, report and run-eval tests all pass. go test -raceon the same test set: 12 race warnings, all inclarify_jobs.goand other files this PR doesn't touch. Main shows the same 12, so none involve the PR's model-cache code.- Behaviour probe (temporary test, not pushed), compared with base
42541ef:- The cross-account model leak is gone in the chat picker, executor picker, guest executor picker, Bot sender check and scheduled runs.
- After a restart, a Bot with a saved concrete model is now accepted after one lookup with the sender's key; the base rejected it.
- the concurrent-picker probe ran 200 times with no concurrent-map panics.
- CI on
8293c66: all 16 checks success.
Non-blocking notes (behaviour already present on main, not caused by this PR):
- A failed model lookup is cached as empty for up to an hour.
- The bot-save check (
assistantKnownCatalog) still validates against all accounts' caches, so a model can be saved and then rejected at run time. - With
AGENTFLOW_ASSISTANT_MODELset, a Bot saved with the empty/default model is still rejected. - Separately, #1000 (
9dcb98a) overlaps this change in 21 of the 24 files, so whichever PR lands second needs a rebase.
No blocking issues found within the scope above. The PR is still a draft, and this approval applies to 8293c66 only.
crispinhu27
left a comment
There was a problem hiding this comment.
Automated CR — APPROVE on head 807784be
Commits reviewed:
8293c66— fix: isolate CodeBuddy model discovery per account (Go backend, 24 files ininternal/httpapi)3bcc48d— merge main into HEADf9f9f49— fix(chat): require a concrete model before sending (chatbot JS, 3 files)807784be— fix(chat): honor personal model defaults for legacy conversations (chatbot JS, 2 files)
CI on 807784be: browser ✅ core ✅ all e2e ✅ first-run ✅ secrets ✅ — all checks passed.
Review of 807784be diff (useChat.js +21-6, hooks.test.jsx +17-6):
preferredModel refactored to accept variadic preferences, iterating until it finds an available concrete model. The loop skips non-concrete IDs (via concreteModel) and also skips IDs not found in the executor catalog, then falls back to available[0]. This correctly handles the four cases the new parametric tests cover: personal default, catalog default, unavailable saved model, and explicit selection.
New state variables accountDefaults and codeBuddyCatalogDefault read from catalog.preferences and catalog.default respectively in applyModelCatalog. Both are sourced from the same /api/assistant/models response already fetched on mount — no extra network call.
inheritsDefault gates the personal-default and catalog-default preference injection to conversations with a non-concrete saved model only, so explicitly selected models are unaffected.
defaultEffort applies the account preference effort only when the catalog entry matches the personal-default model — correct guard preventing effort bleed-over to other models.
No issues found across all four commits. Prior APPROVE on 8293c66 (dismissed by subsequent pushes) covered the Go backend; that code is unchanged here.
Summary
Verification
Reproduced cross-account entries in both pickers on
mainwith two simulated accounts and a guest. The regression test passes with this change.Passed the targeted Go tests for model pickers, personal and shared keys, Bot cold starts, saved scheduled models, reports, run evaluation and clarification.
Passed 471 Chatbot tests. An additional Chromium check selected the account default even when it was second in the list. Chromium covered the missing key, empty model list, and old CLI-default conversation with simulated API responses.
This PR takes over the chat behavior from #1000. Existing server-side model defaults for roles, Bots, scheduled tasks, and older API clients continue to work.