Skip to content

feat(mecatui): switch reasoning effort via conversation fork, keeping the transcript - #290

Merged
JAORMX merged 5 commits into
mainfrom
mecatui-effort-confirm
Jul 21, 2026
Merged

JAORMX merged 5 commits into
mainfrom
mecatui-effort-confirm

Conversation

@JAORMX

@JAORMX JAORMX commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What

Changing reasoning effort mid-conversation no longer wipes the session. The /effort picker now forks the conversation onto a peer session at the picked tier, keeping the transcript — instead of calling restartOnModel (the /models full-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:

  • Wire: ForkSessionRequest gains an optional reasoning_effort = 3 (empty inherits the source's effort verbatim). gRPC + HTTP.
  • Service: Service.ForkSession gains effortOverride, applied only to sel.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.
  • mecatui: 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; a failed fork leaves it open, and enter-to-retry re-forks (a viaFork marker on restartFailedMsg branches 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 / mecademo all green. No engine/ exported API change.

Out of scope

Cross-provider/model carryover (needs replay-blob stripping) — that's issue #20.

… 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]>
@JAORMX
JAORMX requested a review from jhrozek July 21, 2026 13:09

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JAORMX
JAORMX merged commit d9aa054 into main Jul 21, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mecatui: changing reasoning effort mid-conversation resets the whole session

2 participants