Skip to content

fix: isolate CodeBuddy model discovery per account - #1179

Merged
Robert0622 merged 4 commits into
mainfrom
codex/isolate-codebuddy-model-catalog
Nov 21, 2026
Merged

Robert0622 merged 4 commits into
mainfrom
codex/isolate-codebuddy-model-catalog

Conversation

@Robert0622

@Robert0622 Robert0622 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Read automatically discovered CodeBuddy models from the current credential and network environment in the chat and executor pickers.
  • Check explicit model selections using the execution account. Discover its catalog on demand when a saved model is used after a restart.
  • Preserve the CLI default for existing Bot settings and scheduled jobs, along with the platform shared-key allowlist.
  • Keep the draft and show the relevant setup message when chat has no usable model. Conversation creation and generation wait for a model.
  • Reopen chats saved on the CLI default using the account’s configured default model when it is available for that conversation’s CLI. Otherwise use the CLI catalog default or its first available concrete model.

Verification

  • Reproduced cross-account entries in both pickers on main with 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.

crispinhu27
crispinhu27 previously approved these changes Nov 21, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ./... and go vet ./internal/httpapi/ pass on the PR head, on the PR merged with 7dcf3fc, and on the PR merged with 1584230. 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 main 7dcf3fc and nothing else.
  • Merged with 1584230: the model, catalog, sponsor, picker, executor, Bot, clarify, schedule, report and run-eval tests all pass.
  • go test -race on the same test set: 12 race warnings, all in clarify_jobs.go and 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_MODEL set, 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.

@Robert0622
Robert0622 marked this pull request as ready for review November 21, 2026 13:39

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated CR — APPROVE on head 807784be

Commits reviewed:

  • 8293c66 — fix: isolate CodeBuddy model discovery per account (Go backend, 24 files in internal/httpapi)
  • 3bcc48d — merge main into HEAD
  • f9f9f49 — 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.

@Robert0622
Robert0622 merged commit 1cc5db4 into main Nov 21, 2026
15 checks passed
@Robert0622
Robert0622 deleted the codex/isolate-codebuddy-model-catalog branch November 21, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants