fix: always expose the mode selector and make the default model explicit #28

Merged
sam merged 2 commits from fix/mode-selector-and-default-model into main 2026-10-11 09:11:48 +00:00
Collaborator

Problem

Paseo lost the Fast/Default/Deep thinking selector after pi-deploy PR #69 removed the cortects provider from brainless.json. Cortecs models sorted first (cortects/... < local/... < melious/...) and declared reasoningEffort, so they were the registry default and the ACP catalog (session/new with no model selected) advertised modes. With cortects gone the default became the non-reasoning local/gemma4:e2b, and the harness only advertised modes when the default model reasoned — so the catalog returned modes: {availableModes: null} and Paseo showed no selector.

Verified against the running binary: session/new returned only the model config option and null modes; list_models/list_providers showed thinkingOptions: null / modes: [] for the brainless provider.

Changes

  1. 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), and applyModel/applyMode already fall back for presets a model cannot honor. notifyConfigChanged now mirrors modeState(). This is the root-cause fix: the catalog must not depend on which model happens to sort first.

  2. New top-level config.default field. 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, so default only seeds sessions and the catalog's current-value display. Also fixed: ExpandEnv rebuilt File without copying Default, which would have silently dropped a configured default.

  3. history.lastTasks unchanged — off by default (nil block); the deployed config enabled it without a user request. No behavior change here.

Tests

  • TestRegistryConfiguredDefault / TestRegistryDefaultFallsBackToFirstSorted / TestRegistryConfiguredDefaultUnknownModel — new
  • TestLoadParsesDefaultModel / TestLoadRejectsBadDefaultModel — new
  • TestConfigOptionsAdvertiseModelAndMode — catalog now always advertises model + mode; explicit non-reasoning selection drops the mode option
  • e2e catalog assertions updated to the always-expose semantics
  • go test ./... green; go vet clean; golangci-lint only flags a pre-existing varnamelen on NewRegistry's f param (present in HEAD)

Deploy note

Merging builds the rolling latest brainless release; the paseo image must then be rebuilt with --no-cache-filter brainless-fetch and docker compose up -d --force-recreate paseo for Paseo to pick it up.

## Problem Paseo lost the Fast/Default/Deep thinking selector after pi-deploy PR #69 removed the `cortects` provider from `brainless.json`. Cortecs models sorted first (`cortects/...` < `local/...` < `melious/...`) and declared `reasoningEffort`, so they were the registry default and the ACP catalog (`session/new` with no model selected) advertised modes. With cortects gone the default became the non-reasoning `local/gemma4:e2b`, and the harness only advertised modes when the *default* model reasoned — so the catalog returned `modes: {availableModes: null}` and Paseo showed no selector. Verified against the running binary: `session/new` returned only the model config option and null modes; `list_models`/`list_providers` showed `thinkingOptions: null` / `modes: []` for the brainless provider. ## Changes 1. **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), and `applyModel`/`applyMode` already fall back for presets a model cannot honor. `notifyConfigChanged` now mirrors `modeState()`. This is the root-cause fix: the catalog must not depend on which model happens to sort first. 2. **New top-level `config.default` field.** 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, so `default` only seeds sessions and the catalog's current-value display. Also fixed: `ExpandEnv` rebuilt `File` without copying `Default`, which would have silently dropped a configured default. 3. **`history.lastTasks` unchanged** — off by default (nil block); the deployed config enabled it without a user request. No behavior change here. ## Tests - `TestRegistryConfiguredDefault` / `TestRegistryDefaultFallsBackToFirstSorted` / `TestRegistryConfiguredDefaultUnknownModel` — new - `TestLoadParsesDefaultModel` / `TestLoadRejectsBadDefaultModel` — new - `TestConfigOptionsAdvertiseModelAndMode` — catalog now always advertises model + mode; explicit non-reasoning selection drops the mode option - e2e catalog assertions updated to the always-expose semantics - `go test ./...` green; `go vet` clean; `golangci-lint` only flags a pre-existing `varnamelen` on `NewRegistry`'s `f` param (present in HEAD) ## Deploy note Merging builds the rolling `latest` brainless release; the paseo image must then be rebuilt with `--no-cache-filter brainless-fetch` and `docker compose up -d --force-recreate paseo` for Paseo to pick it up.
fix: always expose the mode selector and make the default model explicit
All checks were successful
code-review / Agent review (pull_request) Successful in 8s
0ca2b44663
Paseo lost the Fast/Default/Deep thinking selector after pi-deploy PR #69
removed the cortects provider from brainless.json: cortecs models sorted
first and declared reasoningEffort, so they were the registry default and
the catalog advertised modes. With them gone the default became the
non-reasoning local/gemma4:e2b, and the harness only advertised modes when
the default model reasoned (configOptions/modeState gated on
HasReasoningSelector of the active-or-default ref).

Three changes:

1. The mode selector is now always advertised at catalog time (no explicit
   model selection), so a non-reasoning default can no longer hide it for
   the reasoning models in the config. Per-model gating still applies once
   a model is explicitly selected: a model with no meaningful reasoning
   effort drops the selector, and applyModel/applyMode already fall back
   for presets a model cannot honor. notifyConfigChanged mirrors modeState.

2. New top-level config.default 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 what made the cortects removal silently change the catalog. The
   model config option still lists every model, so default only seeds
   sessions and the catalog's current-value display. ExpandEnv now copies
   the field (it rebuilt File without it, which would have silently
   dropped a configured default).

3. history.lastTasks is unchanged: it stays off by default (nil block);
   the deployed config enabled it without a user request.
pi-reviewer left a comment

Review: fix/mode-selector-and-default-model (PR #28)

Reviewed against head 0ca2b44 (base 5943d68a) 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, gofmt clean, golangci-lint flags only the pre-existing varnamelen on NewRegistry's f param (confirmed identical on main). govulncheck reports 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.default validation (format, unknown provider/model) is correct and tested, the registry default fallback is consistent everywhere Default() 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's default names a declared model and passes Load validation.

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.

## Review: fix/mode-selector-and-default-model (PR #28) Reviewed against head 0ca2b44 (base 5943d68a) 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, `gofmt` clean, `golangci-lint` flags only the pre-existing `varnamelen` on `NewRegistry`'s `f` param (confirmed identical on main). `govulncheck` reports 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.default` validation (format, unknown provider/model) is correct and tested, the registry default fallback is consistent everywhere `Default()` 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's `default` names a declared model and passes `Load` validation. 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))}
Collaborator

🟠 IMPORTANT — the ExpandEnv fix is incomplete: out := File{Version: f.Version, Default: f.Default, Providers: ...} still drops MCPServers, Compaction, Timeouts, Budgets, and History. main.go passes this copy straight to harness.New, which reads those fields from cfg.File (harness.go:190/200/207/217/232), so they are silently lost at boot. The deployed pi-deploy/paseo/brainless.json sets compaction, timeouts, budgets, and history — 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 main 5943d68a), 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 := *f then expand only the provider values), and add a preservation test.

🟠 IMPORTANT — the ExpandEnv fix is incomplete: `out := File{Version: f.Version, Default: f.Default, Providers: ...}` still drops `MCPServers`, `Compaction`, `Timeouts`, `Budgets`, and `History`. `main.go` passes this copy straight to `harness.New`, which reads those fields from `cfg.File` (harness.go:190/200/207/217/232), so they are silently lost at boot. The deployed `pi-deploy/paseo/brainless.json` sets `compaction`, `timeouts`, `budgets`, and `history` — 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 main 5943d68a), 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 := *f` then expand only the provider values), and add a preservation test.
@ -74,6 +74,43 @@ func TestLoadAcceptsMissingAPIKey(t *testing.T) {
}
}
func TestLoadParsesDefaultModel(t *testing.T) {
Collaborator

🟡 SUGGESTION — no regression test covers the ExpandEnv Default fix. TestLoadParsesDefaultModel goes through Load and never calls ExpandEnv, and the existing TestExpandEnvSubstitutesRefs / TestExpandEnvUnsetVarExpandsEmpty build a File without Default. A test asserting Default (and ideally the other top-level fields) survives ExpandEnv would have caught the incomplete-copy issue in config.go — the very bug this PR claims to fix.

🟡 SUGGESTION — no regression test covers the ExpandEnv `Default` fix. `TestLoadParsesDefaultModel` goes through `Load` and never calls `ExpandEnv`, and the existing `TestExpandEnvSubstitutesRefs` / `TestExpandEnvUnsetVarExpandsEmpty` build a `File` without `Default`. A test asserting `Default` (and ideally the other top-level fields) survives `ExpandEnv` would 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) {
Collaborator

🟡 SUGGESTION — stale doc comments vs the new always-expose semantics. The configOptions doc 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 on modeState() is correct; these two were missed).

🟡 SUGGESTION — stale doc comments vs the new always-expose semantics. The `configOptions` doc 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 on `modeState()` is correct; these two were missed).
PR review finding (#28): ExpandEnv rebuilt the File with a selective
constructor that kept Version, Default and Providers but dropped MCPServers,
Compaction, Timeouts, Budgets and History. main.go passes the expanded copy
straight to harness.New, which reads those fields for MCP servers, compaction
settings, per-prompt timeout, task money budget and the measured-history line
— so a configured promptTimeout or maxTaskCost silently never took effect.

ExpandEnv now starts from a full copy of the File and rebuilds only the
provider map, so every top-level block survives expansion untouched. The new
TestExpandEnvPreservesTopLevelFields pins all six fields, which would have
caught the original Default-dropping bug too.

Also updates the two stale options.go doc comments that still described the
old per-default-model mode gating (the mode list is now always advertised at
catalog time; the per-model gate applies only after an explicit selection).
pi-agent left a comment
No description provided.
All three findings resolved in 60e41bd (pushed to fix/mode-selector-and-default-model): 1. **IMPORTANT — ExpandEnv drops MCPServers/Compaction/Timeouts/Budgets/History:** fixed. `ExpandEnv` now starts from a full copy of the File (`out := *f`) and rebuilds only the provider map, so every top-level block survives expansion. New `TestExpandEnvPreservesTopLevelFields` pins Default + all five optional blocks (and that provider expansion still happens), which would also have caught the original Default-dropping bug. 2. **Suggestion — stale doc comments:** updated the mode-constant block comment and the `configOptions` doc comment to match the always-expose-at-catalog / per-model-gate-on-explicit-selection semantics. 3. **Suggestion — ExpandEnv preservation test:** covered by the new test in (1). Verification on the new head: `go build ./...`, `go vet ./...`, `go test ./...`, `go test -race ./internal/harness/` all green; `gofmt` clean; `golangci-lint` only flags the pre-existing `varnamelen` on `NewRegistry`'s `f` param (confirmed identical on main).
sam merged commit 763656b5ea into main 2026-10-11 09:11:48 +00:00
sam deleted branch fix/mode-selector-and-default-model 2026-10-11 09:11:48 +00:00
Sign in to join this conversation.
No reviewers
No labels
code-review
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sam/brainless!28
No description provided.