fix: always expose the mode selector and make the default model explicit #28
No reviewers
Labels
No labels
code-review
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
sam/brainless!28
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/mode-selector-and-default-model"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Paseo lost the Fast/Default/Deep thinking selector after pi-deploy PR #69 removed the
cortectsprovider frombrainless.json. Cortecs models sorted first (cortects/...<local/...<melious/...) and declaredreasoningEffort, so they were the registry default and the ACP catalog (session/newwith no model selected) advertised modes. With cortects gone the default became the non-reasoninglocal/gemma4:e2b, and the harness only advertised modes when the default model reasoned — so the catalog returnedmodes: {availableModes: null}and Paseo showed no selector.Verified against the running binary:
session/newreturned only the model config option and null modes;list_models/list_providersshowedthinkingOptions: null/modes: []for the brainless provider.Changes
Always expose the mode selector at catalog time.
configOptions()/modeState()no longer gate on the default model's reasoning. Once a model is explicitly selected, per-model gating still applies (a model with no meaningful reasoning effort drops the selector), andapplyModel/applyModealready fall back for presets a model cannot honor.notifyConfigChangednow mirrorsmodeState(). This is the root-cause fix: the catalog must not depend on which model happens to sort first.New top-level
config.defaultfield. Names the model fresh sessions start on as"provider/model"; omitted falls back to the first model in sorted order. Previously the default was implicit (first sorted entry), which is exactly what made the cortects removal silently change the catalog. The model config option still lists every model, sodefaultonly seeds sessions and the catalog's current-value display. Also fixed:ExpandEnvrebuiltFilewithout copyingDefault, which would have silently dropped a configured default.history.lastTasksunchanged — off by default (nil block); the deployed config enabled it without a user request. No behavior change here.Tests
TestRegistryConfiguredDefault/TestRegistryDefaultFallsBackToFirstSorted/TestRegistryConfiguredDefaultUnknownModel— newTestLoadParsesDefaultModel/TestLoadRejectsBadDefaultModel— newTestConfigOptionsAdvertiseModelAndMode— catalog now always advertises model + mode; explicit non-reasoning selection drops the mode optiongo test ./...green;go vetclean;golangci-lintonly flags a pre-existingvarnamelenonNewRegistry'sfparam (present in HEAD)Deploy note
Merging builds the rolling
latestbrainless release; the paseo image must then be rebuilt with--no-cache-filter brainless-fetchanddocker compose up -d --force-recreate paseofor Paseo to pick it up.Review: fix/mode-selector-and-default-model (PR #28)
Reviewed against head
0ca2b44(base5943d68a) with the samber/cc-skills-golang pass methodology (code quality, correctness/safety, security/deps, tests/perf/observability/modernize). Verification run in this session against the PR head:go build ./...clean,go vet ./...clean,go test ./...all packages green,go test -race ./internal/harness/green,gofmtclean,golangci-lintflags only the pre-existingvarnamelenonNewRegistry'sfparam (confirmed identical on main).govulncheckreports stdlib/import vulnerabilities but the PR adds no dependencies, so nothing here is introduced by this PR.The core change is sound: always exposing the mode selector at catalog time and gating per model only after an explicit selection is the right root-cause fix,
config.defaultvalidation (format, unknown provider/model) is correct and tested, the registry default fallback is consistent everywhereDefault()is consumed (fresh-session seeding, catalog current-value, selector model name), and the concurrency story is unchanged (registry immutable, selection mutex-guarded; race detector clean). The example config'sdefaultnames a declared model and passesLoadvalidation.One IMPORTANT finding and two suggestions — no blocking issues introduced by this PR. The IMPORTANT item is pre-existing on main, but it sits on the exact line this PR modified and the PR claims to fix that bug class, so completing it here is a one-line change.
@ -406,3 +427,3 @@// require an API key.func (f *File) ExpandEnv(lookup func(string) (string, bool)) (*File, error) {out := File{Version: f.Version, Providers: make(map[string]Provider, len(f.Providers))}out := File{Version: f.Version, Default: f.Default, Providers: make(map[string]Provider, len(f.Providers))}🟠 IMPORTANT — the ExpandEnv fix is incomplete:
out := File{Version: f.Version, Default: f.Default, Providers: ...}still dropsMCPServers,Compaction,Timeouts,Budgets, andHistory.main.gopasses this copy straight toharness.New, which reads those fields fromcfg.File(harness.go:190/200/207/217/232), so they are silently lost at boot. The deployedpi-deploy/paseo/brainless.jsonsetscompaction,timeouts,budgets, andhistory— meaning prompt timeouts and money budgets currently never take effect in the running binary. Verified this session: a field-preservation test fails with 'MCPServers dropped by ExpandEnv', 'Compaction dropped by ExpandEnv', 'Timeouts dropped by ExpandEnv', 'Budgets dropped by ExpandEnv', 'History dropped by ExpandEnv'. This predates the PR (same constructor on main5943d68a), so it is not a regression — but the PR body claims to fix exactly this bug class ('ExpandEnv rebuilt File without copying Default, which would have silently dropped a configured default'), and the fix is one line away from complete. Fix: copy the remaining top-level fields (e.g.out := *fthen expand only the provider values), and add a preservation test.@ -74,6 +74,43 @@ func TestLoadAcceptsMissingAPIKey(t *testing.T) {}}func TestLoadParsesDefaultModel(t *testing.T) {🟡 SUGGESTION — no regression test covers the ExpandEnv
Defaultfix.TestLoadParsesDefaultModelgoes throughLoadand never callsExpandEnv, and the existingTestExpandEnvSubstitutesRefs/TestExpandEnvUnsetVarExpandsEmptybuild aFilewithoutDefault. A test assertingDefault(and ideally the other top-level fields) survivesExpandEnvwould have caught the incomplete-copy issue in config.go — the very bug this PR claims to fix.@ -271,0 +285,4 @@// the per-model gate stands: a model with no reasoning effort other than// off/none drops the selector, and applyModel/applyMode fall back to// default for a model that cannot honor a preset.if h.explicitSelection() && !h.reg.HasReasoningSelector(ref) {🟡 SUGGESTION — stale doc comments vs the new always-expose semantics. The
configOptionsdoc comment above this function still says the mode selector is advertised 'when the active model meaningfully reasons', and the mode-constant block comment (options.go ~line 28) still says 'modes are only advertised for models that meaningfully reason'. Both contradict the new behavior: at catalog time the selector is advertised unconditionally, and the per-model gate only applies once a model is explicitly selected. Update both comments to match the code (the new comment onmodeState()is correct; these two were missed).