Skip to content

Commit 14070d6

Browse files
committed
Fix spurious session restarts on runtime-mode-set and remove dead fallback chain in plan implementation
- Remove fallback to toProviderModelOptions(thread.modelSelection) in the thread.runtime-mode-set handler. Before any turn was sent, the fallback would produce defined modelOptions while the cache had none, causing sameModelOptions(undefined, derivedOptions) to return false and triggering an unnecessary session restart for Claude threads. - Simplify nextThreadModelSelection in ChatView to use selectedModelSelection directly, removing unreachable ?? fallbacks (selectedModelSelection is always a non-null ModelSelection from useMemo).
1 parent 8cad01a commit 14070d6

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

apps/server/src/orchestration/Layers/ProviderCommandReactor.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,9 +705,7 @@ const make = Effect.gen(function* () {
705705
return;
706706
}
707707
const cachedProviderOptions = threadProviderOptions.get(event.payload.threadId);
708-
const cachedModelOptions =
709-
threadModelOptions.get(event.payload.threadId) ??
710-
toProviderModelOptions(thread.modelSelection);
708+
const cachedModelOptions = threadModelOptions.get(event.payload.threadId);
711709
yield* ensureSessionForThread(event.payload.threadId, event.occurredAt, {
712710
...(cachedProviderOptions !== undefined
713711
? { providerOptions: cachedProviderOptions }

apps/web/src/components/ChatView.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,12 +3035,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
30353035
text: implementationPrompt,
30363036
});
30373037
const nextThreadTitle = truncateTitle(buildPlanImplementationThreadTitle(planMarkdown));
3038-
const nextThreadModelSelection: ModelSelection = selectedModelSelection ??
3039-
activeThread.modelSelection ??
3040-
activeProject.defaultModelSelection ?? {
3041-
provider: "codex",
3042-
model: DEFAULT_MODEL_BY_PROVIDER.codex,
3043-
};
3038+
const nextThreadModelSelection: ModelSelection = selectedModelSelection;
30443039

30453040
sendInFlightRef.current = true;
30463041
beginSendPhase("sending-turn");

0 commit comments

Comments
 (0)