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.
Unified · Split
| @@ -13,7 +13,7 @@ import { · 12 unmodified lines | |||
| 13 | type RuntimeMode, | 13 | type RuntimeMode, |
| 14 | type TurnId, | 14 | type TurnId, |
| 15 | } from "@t3tools/contracts"; | 15 | } from "@t3tools/contracts"; |
| 16 | import { Cache, Cause, Duration, Effect, Equal, Layer, Option, Schema, Stream } from "effect"; | 16 | import { Cache, Cause, Duration, Effect, Layer, Option, Schema, Stream } from "effect"; |
| 17 | import { makeDrainableWorker } from "@t3tools/shared/DrainableWorker"; | 17 | import { makeDrainableWorker } from "@t3tools/shared/DrainableWorker"; |
| 18 | 18 | ||
| 19 | import { resolveThreadWorkspaceCwd } from "../../checkpointing/Utils.ts"; | 19 | import { resolveThreadWorkspaceCwd } from "../../checkpointing/Utils.ts"; |
| @@ -301,7 +301,7 @@ const make = Effect.gen(function* () { · 281 unmodified lines | |||
| 301 | const shouldRestartForModelSelectionChange = | 301 | const shouldRestartForModelSelectionChange = |
| 302 | currentProvider === "claudeAgent" && | 302 | currentProvider === "claudeAgent" && |
| 303 | requestedModelSelection !== undefined && | 303 | requestedModelSelection !== undefined && |
| 304 | !Equal.equals(previousModelSelection, requestedModelSelection); | 304 | JSON.stringify(previousModelSelection) !== JSON.stringify(requestedModelSelection); |
| 305 | 305 | ||
| 306 | if ( | 306 | if ( |
| 307 | !runtimeModeChanged && | 307 | !runtimeModeChanged && |