Fix: replace Equal.equals with JSON.stringify comparison for ModelSelection

Equal.equals falls back to reference equality (===) for plain objects
without the Equal trait. Since ModelSelection objects are plain JS objects
created via Schema.Struct/Schema.Union, two identical selections would
always compare as different, causing unnecessary session restarts on every
Claude turn.
This commit is contained in:
Cursor Agent committed 2026-03-24 23:17:56 +00:00
1 parent e0d4388c77
commit 7d1604932b
1 file changed
+2 -2
@@ -13,7 +13,7 @@ import {
type RuntimeMode,
type TurnId,
} from "@t3tools/contracts";
import { Cache, Cause, Duration, Effect, Equal, Layer, Option, Schema, Stream } from "effect";
import { Cache, Cause, Duration, Effect, Layer, Option, Schema, Stream } from "effect";
import { makeDrainableWorker } from "@t3tools/shared/DrainableWorker";
import { resolveThreadWorkspaceCwd } from "../../checkpointing/Utils.ts";
@@ -301,7 +301,7 @@ const make = Effect.gen(function* () {
const shouldRestartForModelSelectionChange =
currentProvider === "claudeAgent" &&
requestedModelSelection !== undefined &&
!Equal.equals(previousModelSelection, requestedModelSelection);
JSON.stringify(previousModelSelection) !== JSON.stringify(requestedModelSelection);
if (
!runtimeModeChanged &&