[Bug] /fork reverts to the CLI --model/--thinking instead of the model selected in the session #2048
israellot
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Forking a session (
/fork, or theforkdaemon/RPC command) does not keep the model and thinking level that were active in the source session. The forked session comes up with the model/thinking level from the CLI launch config (--model,--thinking) instead.Repro
prime-agent --model <provider>/<model-A>(interactive or--mode rpc)./model(orset_model), optionally change/effort./forkfrom any earlier user message (or fork "at" the current position).It only reproduces when a
--modelwas given at launch. Without it,createAgentSessionrestores the model from the transcript and it looks fine./resumeand/neware not affected in the same way.Root cause
AgentSessionRuntime.fork()inpackages/coding-agent/src/core/agent-session-runtime.tsrebuilds the runtime with onlysessionConfig: this.sessionConfigand nosessionOptions.createRuntimeinmain.tsthen runsbuildSessionOptions(config, ...), which resolvesconfig.model/config.thinkingfrom the startup config, and the explicit CLI model wins over the transcript'smodel_changeentries increateAgentSession.Still present on
upstream/mainat3484f06a1.Fix
Capture the live session's
model,thinkingLevel,serviceTier, andscopedModelsbefore the fork and pass them assessionOptionson all three fork paths.resolveRuntimeSessionOptionsalready givessessionOptionsprecedence over the CLI config, so no other changes are needed.Patch with a regression test and a
.changesfragment, rebased onupstream/main:israellot@36284ef
(branch
fix/fork-keeps-session-model, +50/-0 across 3 files)Validation: the new test fails on
main(Expected "faux-2", Received "faux-1") and passes with the patch;test/suite/agent-session-runtime.test.ts,test/daemon-mode.test.ts,test/interactive-mode-clone-command.test.ts, and the 2860 regression test pass;tsgo --noEmitandbiome checkare clean.Happy to open the PR if a maintainer wants it.
All reactions