Repository navigation
feat(mecatui): switch reasoning effort via conversation fork, keeping the transcript - #290
Conversation
… the transcript (#246) The /effort picker called restartOnModel on enter — the same full teardown /models uses — so changing effort mid-conversation wiped the transcript, usage, and all per-session client state. The operator's real need is to resume the conversation at the new effort, not to be warned before losing it. Reuse the ADR 0065 conversation fork: add an optional reasoning_effort override to ForkSession (wire: gRPC + HTTP) and have the /effort picker fork the conversation onto a peer session at the picked tier instead of create-fresh. Same provider and model, so the replay blobs (Message.Reasoning/ProviderPhase/ItemID) stay valid and the context window is unchanged — no turn-zero compaction. The new switchEffort handoff mirrors restartOnModel but deliberately omits resetSession(); the transcript survives and the UI rebinds to the new session id on SessionReadyMsg. The old session is closed best-effort after a successful fork (engine-slot hygiene); a failed fork leaves it open, and enter-to-retry re-forks rather than falling back to the transcript-wiping create path (a viaFork marker on restartFailedMsg branches the retry). - proto: ForkSessionRequest.reasoning_effort = 3 (optional; empty inherits the source's effort verbatim). task generate regenerated contracts/gen + llms.txt. - Service.ForkSession gains effortOverride, applied ONLY to sel.ReasoningEffort; provider/model always inherit (ADR 0065's same-provider/model constraint). Effort string re-validates through the ADR 0055 single validator at the engine factory, then fail-soft at the adapters — no arbitrary token reaches a provider param. - mecatui: SessionCreator.ForkSession + client.ForkSession. New ADR 0066 documents the decision; ADR 0065 stays frozen. Tests pin the headline invariant (transcript preserved across fork + SessionReadyMsg, anti-resetSession), the effort landing on the forked session + engine rehydrate echo, provider/model inheritance, empty- override inherit, success-closes-old / failure-leaves-open, gRPC+HTTP override round-trips, failed-fork retry re-forks, refetch-failure graceful degradation, non-auto current-tier re-pick, and queued mid-run fork-after-run-end ordering. e2e teatests cover the fork and failure paths. task test / task lint / task api:check / mecademo green. Co-authored-by: Claude Opus 4.8 <[email protected]>
jhrozek
left a comment
There was a problem hiding this comment.
Approving — clean reuse of the ADR 0065 fork primitive, backward-compatible wire change, and genuinely thorough test coverage. The core invariant (transcript survives the effort switch) is correct and well-guarded.
nit (non-blocking): In switchEffortCmd, when the fork succeeds but the follow-up GetSession refetch fails, the code closes the source, discards the good newID, and arms an enter-retry that re-forks from scratch. The retry works (CloseSession doesn't delete the snapshot, so loadAndReopen reloads it), but the good fork is orphaned server-side and the user redoes work already done. Since the ADR says the resolved-model echo is non-essential ("footer self-corrects from SessionReadyMsg + turn-end refetch"), the tidier path is to adopt newID on refetch failure — return SessionReadyMsg{SessionID: newID, ResolvedModel: {}} rather than throwing it away. TestEffortPickRefetchFailureKeepsFork's comment ("the fork happened") reads like this was the intent. Fine as a follow-up.
# Conflicts: # llms.txt
# Conflicts: # llms.txt
What
Changing reasoning effort mid-conversation no longer wipes the session. The
/effortpicker now forks the conversation onto a peer session at the picked tier, keeping the transcript — instead of callingrestartOnModel(the/modelsfull-teardown handoff) on enter.Closes #246.
Why
Issue #246 reported that picking a new effort tier reset the whole session (transcript, usage, per-session state). The operator's real need was to resume the conversation at the new effort, not to be warned before losing it.
How
Reuses the ADR 0065 conversation fork:
ForkSessionRequestgains an optionalreasoning_effort = 3(empty inherits the source's effort verbatim). gRPC + HTTP.Service.ForkSessiongainseffortOverride, applied only tosel.ReasoningEffort; provider/model always inherit (ADR 0065's same-provider/model constraint is what keeps the replay blobs valid). The effort string re-validates through the ADR 0055 single validator at the engine factory, then fail-soft at the adapters.switchEfforthandoff mirrorsrestartOnModelbut deliberately omitsresetSession()— the transcript survives and the UI rebinds to the new session id onSessionReadyMsg. The old session is closed best-effort after a successful fork; a failed fork leaves it open, and enter-to-retry re-forks (aviaForkmarker onrestartFailedMsgbranches the retry) rather than falling back to the transcript-wiping create path.Same provider + model ⇒ no turn-zero compaction, replay blobs valid. New ADR 0066 documents the decision; ADR 0065 stays frozen.
Tests
The headline invariant is pinned: transcript preserved across fork + SessionReadyMsg (anti-
resetSession), at both unit and teatest-e2e level. Also: effort landing on the forked session + engine-rehydrate echo, provider/model inheritance, empty-override inherit, success-closes-old / failure-leaves-open, gRPC+HTTP override round-trips, failed-fork retry re-forks, refetch-failure graceful degradation, non-auto current-tier re-pick, and queued mid-run fork-after-run-end ordering.task test/task lint/task api:check/mecademoall green. Noengine/exported API change.Out of scope
Cross-provider/model carryover (needs replay-blob stripping) — that's issue #20.