fix: expose model-dependent reasoning modes as a config option #16

Merged
sam merged 2 commits from fix/mode-as-config-option into main 2026-09-26 16:37:55 +00:00
Collaborator

Problem

After #14, reasoning control is mode-only, and the mode selector is supposed to be hidden for models that do not meaningfully reason. But in Paseo the Change Mode selector still showed for a non-reasoning model (e.g. local Gemma, no reasoningEffort, or a model declaring only off).

Root cause (mine, in brainless): the modes were advertised only as ACP session mode state. ACP conveys SessionModeState exclusively in session/new / load / resume. At session start the active model is the config default (which reasons, so modes are advertised); when the client then switches to a non-reasoning model there is no channel for the agent to say the mode list changed, so the client kept the stale selector.

Fix

Advertise the modes as a mode config option (category mode) in addition to the session mode state, and push config_option_update + current_mode_update whenever a config option changes. Clients (Paseo) re-derive the mode selector from the updated config options, so the mode option is present for models that meaningfully reason and is dropped — hiding the selector — otherwise.

  • configOptions() adds the mode option only when the active model declares a reasoning effort other than off/none.
  • SetSessionConfigOption now handles the mode config id and pushes the notifications; applyMode/applyModel are shared with SetSessionMode.

Verification (ACP level, live config)

initial (default model)     sessionModes=[fast default deep] configOptions=[model mode]
switch -> reasoning model   response=[model mode]  pushed config_option_update=[model mode]
switch -> Gemma (no reason) response=[model]       pushed config_option_update=[model]   <-- selector hidden
  • go build, go test ./..., golangci-lint run ./..., racedetector test clean.
  • New tests: TestConfigOptionsAdvertiseModelAndMode, TestACPConfigOptionUpdateOnModelSwitch.

Branched from latest main (448131d).

## Problem After #14, reasoning control is mode-only, and the mode selector is supposed to be hidden for models that do not meaningfully reason. But in Paseo the **Change Mode** selector still showed for a non-reasoning model (e.g. local Gemma, no `reasoningEffort`, or a model declaring only `off`). Root cause (mine, in brainless): the modes were advertised only as ACP **session mode state**. ACP conveys `SessionModeState` exclusively in `session/new` / `load` / `resume`. At session start the active model is the config default (which reasons, so modes are advertised); when the client then switches to a non-reasoning model there is no channel for the agent to say the mode list changed, so the client kept the stale selector. ## Fix Advertise the modes as a **`mode` config option** (category `mode`) in addition to the session mode state, and push `config_option_update` + `current_mode_update` whenever a config option changes. Clients (Paseo) re-derive the mode selector from the updated config options, so the `mode` option is present for models that meaningfully reason and is dropped — hiding the selector — otherwise. - `configOptions()` adds the `mode` option only when the active model declares a reasoning effort other than `off`/`none`. - `SetSessionConfigOption` now handles the `mode` config id and pushes the notifications; `applyMode`/`applyModel` are shared with `SetSessionMode`. ## Verification (ACP level, live config) ``` initial (default model) sessionModes=[fast default deep] configOptions=[model mode] switch -> reasoning model response=[model mode] pushed config_option_update=[model mode] switch -> Gemma (no reason) response=[model] pushed config_option_update=[model] <-- selector hidden ``` - `go build`, `go test ./...`, `golangci-lint run ./...`, `racedetector test` clean. - New tests: `TestConfigOptionsAdvertiseModelAndMode`, `TestACPConfigOptionUpdateOnModelSwitch`. Branched from latest `main` (448131d).
fix: expose model-dependent reasoning modes as a config option
All checks were successful
code-review / Agent review (pull_request) Successful in 9s
8c165c6c59
Reasoning modes were advertised only as ACP session mode state, which ACP
conveys exclusively in session/new, load, and resume. A client therefore
cannot learn that the mode list changed when the model changes, so
switching to a model with no meaningful reasoning (a model with no declared
reasoningEffort, or one declaring only off/none) left a stale 'Change Mode'
selector in Paseo.

Advertise the modes as a 'mode' config option (category mode) as well, and
push config_option_update plus current_mode_update whenever a config option
changes. The client re-derives the mode selector from the updated config
options, so the mode option is present for models that meaningfully reason
and dropped otherwise, hiding the selector.

- configOptions() adds the mode option only when the active model declares a
  reasoning effort other than off/none.
- SetSessionConfigOption handles the 'mode' config id and pushes the
  notifications; applyMode/applyModel are shared with SetSessionMode.
- Tests: mode option advertised per model, and a config_option_update
  carrying [model] (no mode) on a switch to a non-reasoning model.
pi-reviewer left a comment

Solid, well-scoped change. Advertises the reasoning modes as a mode config option (category mode) alongside the session mode state, and pushes config_option_update + current_mode_update on config-option changes so a client can re-derive the mode selector when the model changes (ACP only conveys SessionModeState at session start).

Verified in this session (worktree at head 8c165c6, Go 1.27.1): go build ./... clean, go vet ./... clean, go test ./... all pass, and the two new tests (TestConfigOptionsAdvertiseModelAndMode, TestACPConfigOptionUpdateOnModelSwitch) pass and are race-clean under racedetector. No changes to go.mod/go.sum and no new imports. selection is mutex-guarded, so the unlocked h.sel.modeSnap() in notifyConfigChanged is safe; configOptions() cannot fail after a successful applyModel/applyMode because the selection is then non-empty. Doc comments (options.go, README) are accurate.

Two minor (non-blocking) observations — see inline comments:

  1. session/set_mode (SetSessionMode) does not push the notifications the new config-option path does, leaving the two mode-change paths asymmetric.
  2. On a switch to a non-reasoning model, current_mode_update reports mode default even though modeState() advertises no current mode for such models.

No blocking issues found.

Solid, well-scoped change. Advertises the reasoning modes as a `mode` config option (category `mode`) alongside the session mode state, and pushes `config_option_update` + `current_mode_update` on config-option changes so a client can re-derive the mode selector when the model changes (ACP only conveys SessionModeState at session start). Verified in this session (worktree at head 8c165c6, Go 1.27.1): `go build ./...` clean, `go vet ./...` clean, `go test ./...` all pass, and the two new tests (`TestConfigOptionsAdvertiseModelAndMode`, `TestACPConfigOptionUpdateOnModelSwitch`) pass and are race-clean under `racedetector`. No changes to go.mod/go.sum and no new imports. `selection` is mutex-guarded, so the unlocked `h.sel.modeSnap()` in `notifyConfigChanged` is safe; `configOptions()` cannot fail after a successful `applyModel`/`applyMode` because the selection is then non-empty. Doc comments (options.go, README) are accurate. Two minor (non-blocking) observations — see inline comments: 1. `session/set_mode` (`SetSessionMode`) does not push the notifications the new config-option path does, leaving the two mode-change paths asymmetric. 2. On a switch to a non-reasoning model, `current_mode_update` reports mode `default` even though `modeState()` advertises no current mode for such models. No blocking issues found.
@ -448,0 +473,4 @@
ConfigOptionUpdate: &acp.SessionConfigOptionUpdate{ConfigOptions: opts},
})
h.sessionUpdate(ctx, conn, sid, acp.SessionUpdate{
CurrentModeUpdate: &acp.SessionCurrentModeUpdate{CurrentModeId: h.sel.modeSnap()},
Collaborator

🟡 SUGGESTION — On a switch to a non-reasoning model, applyModel forces mode→default, so h.sel.modeSnap() here returns default and the agent pushes current_mode_update{currentModeId:"default"} for a model that, per modeState() (options.go), advertises &acp.SessionModeState{} — no available modes, no current mode. The two paths disagree about whether such a model has a current mode. Harmless in practice (the client hides the selector), but for consistency consider skipping this current_mode_update when the active model has no reasoning selector (!h.reg.HasReasoningSelector(ref)), or pushing an empty current mode, matching modeState().

🟡 SUGGESTION — On a switch to a non-reasoning model, `applyModel` forces mode→default, so `h.sel.modeSnap()` here returns `default` and the agent pushes `current_mode_update{currentModeId:"default"}` for a model that, per `modeState()` (options.go), advertises `&acp.SessionModeState{}` — no available modes, no current mode. The two paths disagree about whether such a model has a current mode. Harmless in practice (the client hides the selector), but for consistency consider skipping this `current_mode_update` when the active model has no reasoning selector (`!h.reg.HasReasoningSelector(ref)`), or pushing an empty current mode, matching `modeState()`.
@ -50,3 +54,2 @@
func (h *Harness) SetSessionMode(_ context.Context, req acp.SetSessionModeRequest) (acp.SetSessionModeResponse, error) {
if !slices.ContainsFunc(acpModes(), func(m acp.SessionMode) bool { return m.Id == req.ModeId }) {
return acp.SetSessionModeResponse{}, fmt.Errorf("unknown mode %q", req.ModeId)
if err := h.applyMode(req.ModeId); err != nil {
Collaborator

🟡 SUGGESTION — Notification asymmetry between the two mode-change paths. SetSessionConfigOption (line 173) pushes config_option_update + current_mode_update after a mode/model change, but the ACP-native session/set_mode RPC (SetSessionMode) changes the mode without pushing either, and SetSessionModeResponse carries no mode state (verified: go doc shows only Meta). So when a client switches mode via set_session_mode its locally-rendered mode CurrentValue is only corrected on the next full config-option advertisement. Not blocking — the client that called set_mode already knows the mode it set — but since this PR is precisely about keeping the client's mode selector fresh, delegating SetSessionMode through the same notification path would make the two paths consistent.

🟡 SUGGESTION — Notification asymmetry between the two mode-change paths. `SetSessionConfigOption` (line 173) pushes `config_option_update` + `current_mode_update` after a mode/model change, but the ACP-native `session/set_mode` RPC (`SetSessionMode`) changes the mode without pushing either, and `SetSessionModeResponse` carries no mode state (verified: `go doc` shows only `Meta`). So when a client switches mode via `set_session_mode` its locally-rendered mode `CurrentValue` is only corrected on the next full config-option advertisement. Not blocking — the client that called set_mode already knows the mode it set — but since this PR is precisely about keeping the client's mode selector fresh, delegating `SetSessionMode` through the same notification path would make the two paths consistent.
Address two review suggestions on #16:

- SetSessionMode (the ACP-native session/set_mode path) now pushes the same
  config_option_update + current_mode_update as SetSessionConfigOption, so a
  client's mode selector stays fresh whichever RPC changed the mode.
- notifyConfigChanged reports an empty current mode when the active model has
  no reasoning selector, matching modeState() (which advertises no current
  mode for such a model) instead of the internally stored "default". The
  update is still sent, because the client re-emits its mode-changed event
  from it, which is what drops the selector for such a model.
Author
Collaborator

Both suggestions addressed in 95128bc.

🟡 608 — set_mode/config-option notification asymmetry: Fixed. SetSessionMode now routes through the same configOptions() + notifyConfigChanged() path as SetSessionConfigOption, so session/set_mode and the config-option path push identical config_option_update + current_mode_update updates. Test: extended TestACPConfigOptionUpdateOnModelSwitch to switch mode via SetSessionMode and assert the notifications arrive.

🟡 607 — current_mode_update vs modeState() disagreement: Fixed by reporting an empty current mode (not skipping) when the active model has no reasoning selector, matching modeState() which advertises no current mode for such a model. It stays an empty update rather than a skipped one because the client re-emits its mode-changed event from that notification, which is what drops the selector for the non-reasoning model. notifyConfigChanged now derives the id via the shared activeRef() + HasReasoningSelector. Test: asserts currentMode="" after switching to the non-reasoning model and the real mode id otherwise.

go build, go test ./..., golangci-lint run ./..., racedetector test all clean.

Both suggestions addressed in `95128bc`. **🟡 608 — set_mode/config-option notification asymmetry:** Fixed. `SetSessionMode` now routes through the same `configOptions()` + `notifyConfigChanged()` path as `SetSessionConfigOption`, so `session/set_mode` and the config-option path push identical `config_option_update` + `current_mode_update` updates. Test: extended `TestACPConfigOptionUpdateOnModelSwitch` to switch mode via `SetSessionMode` and assert the notifications arrive. **🟡 607 — current_mode_update vs modeState() disagreement:** Fixed by reporting an **empty** current mode (not skipping) when the active model has no reasoning selector, matching `modeState()` which advertises no current mode for such a model. It stays an empty *update* rather than a skipped one because the client re-emits its mode-changed event from that notification, which is what drops the selector for the non-reasoning model. `notifyConfigChanged` now derives the id via the shared `activeRef()` + `HasReasoningSelector`. Test: asserts `currentMode=""` after switching to the non-reasoning model and the real mode id otherwise. `go build`, `go test ./...`, `golangci-lint run ./...`, `racedetector test` all clean.
sam merged commit 92a6ddae15 into main 2026-09-26 16:37:55 +00:00
sam deleted branch fix/mode-as-config-option 2026-09-26 16:37:55 +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!16
No description provided.