fix: expose model-dependent reasoning modes as a config option #16
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!16
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/mode-as-config-option"
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
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 onlyoff).Root cause (mine, in brainless): the modes were advertised only as ACP session mode state. ACP conveys
SessionModeStateexclusively insession/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
modeconfig option (categorymode) in addition to the session mode state, and pushconfig_option_update+current_mode_updatewhenever a config option changes. Clients (Paseo) re-derive the mode selector from the updated config options, so themodeoption is present for models that meaningfully reason and is dropped — hiding the selector — otherwise.configOptions()adds themodeoption only when the active model declares a reasoning effort other thanoff/none.SetSessionConfigOptionnow handles themodeconfig id and pushes the notifications;applyMode/applyModelare shared withSetSessionMode.Verification (ACP level, live config)
go build,go test ./...,golangci-lint run ./...,racedetector testclean.TestConfigOptionsAdvertiseModelAndMode,TestACPConfigOptionUpdateOnModelSwitch.Branched from latest
main(448131d).Solid, well-scoped change. Advertises the reasoning modes as a
modeconfig option (categorymode) alongside the session mode state, and pushesconfig_option_update+current_mode_updateon 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 underracedetector. No changes to go.mod/go.sum and no new imports.selectionis mutex-guarded, so the unlockedh.sel.modeSnap()innotifyConfigChangedis safe;configOptions()cannot fail after a successfulapplyModel/applyModebecause the selection is then non-empty. Doc comments (options.go, README) are accurate.Two minor (non-blocking) observations — see inline comments:
session/set_mode(SetSessionMode) does not push the notifications the new config-option path does, leaving the two mode-change paths asymmetric.current_mode_updatereports modedefaulteven thoughmodeState()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()},🟡 SUGGESTION — On a switch to a non-reasoning model,
applyModelforces mode→default, soh.sel.modeSnap()here returnsdefaultand the agent pushescurrent_mode_update{currentModeId:"default"}for a model that, permodeState()(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 thiscurrent_mode_updatewhen the active model has no reasoning selector (!h.reg.HasReasoningSelector(ref)), or pushing an empty current mode, matchingmodeState().@ -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 {🟡 SUGGESTION — Notification asymmetry between the two mode-change paths.
SetSessionConfigOption(line 173) pushesconfig_option_update+current_mode_updateafter a mode/model change, but the ACP-nativesession/set_modeRPC (SetSessionMode) changes the mode without pushing either, andSetSessionModeResponsecarries no mode state (verified:go docshows onlyMeta). So when a client switches mode viaset_session_modeits locally-rendered modeCurrentValueis 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, delegatingSetSessionModethrough the same notification path would make the two paths consistent.Both suggestions addressed in
95128bc.🟡 608 — set_mode/config-option notification asymmetry: Fixed.
SetSessionModenow routes through the sameconfigOptions()+notifyConfigChanged()path asSetSessionConfigOption, sosession/set_modeand the config-option path push identicalconfig_option_update+current_mode_updateupdates. Test: extendedTestACPConfigOptionUpdateOnModelSwitchto switch mode viaSetSessionModeand 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.notifyConfigChangednow derives the id via the sharedactiveRef()+HasReasoningSelector. Test: assertscurrentMode=""after switching to the non-reasoning model and the real mode id otherwise.go build,go test ./...,golangci-lint run ./...,racedetector testall clean.