Skip to content

Commit 53f4b61

Browse files
only21milclaude
andcommitted
fix(claude): pass --no-session-persistence only to Claude Code 2.0.63+
Claude Code 2.0.60-2.0.62 run text generation but reject --no-session-persistence as an unknown option. Read the version the provider probe already detects and pass the flag only when it is 2.0.63 or newer; an unknown version omits it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2a47975 commit 53f4b61

4 files changed

Lines changed: 64 additions & 2 deletions

File tree

‎apps/server/src/provider/Drivers/ClaudeDriver.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
193193
);
194194
const textGeneration = yield* makeClaudeTextGeneration(
195195
effectiveConfig,
196+
Effect.suspend(() => snapshot.getSnapshot).pipe(Effect.map((current) => current.version)),
196197
processEnv,
197198
modelCatalog,
198199
);

‎apps/server/src/textGeneration/ClaudeTextGeneration.test.ts‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ function makeFakeClaudeBinary(dir: string, lifecyclePort?: number) {
5757
function withFakeClaudeEnv<A, E, R>(
5858
input: {
5959
output: string;
60+
cliVersion?: string | null;
61+
rejectsNoSessionPersistence?: boolean;
6062
lifecyclePort?: number;
6163
exitCode?: number;
6264
stderr?: string;
@@ -75,6 +77,8 @@ function withFakeClaudeEnv<A, E, R>(
7577
const binDir = yield* makeFakeClaudeBinary(tempDir, input.lifecyclePort);
7678
const pathDelimiter = (yield* HostProcess.isWindows) ? ";" : ":";
7779
const previousPath = process.env.PATH;
80+
const previousRejectsNoSessionPersistence =
81+
process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE;
7882
const previousOutput = process.env.T3_FAKE_CLAUDE_OUTPUT;
7983
const previousExitCode = process.env.T3_FAKE_CLAUDE_EXIT_CODE;
8084
const previousStderr = process.env.T3_FAKE_CLAUDE_STDERR;
@@ -89,6 +93,12 @@ function withFakeClaudeEnv<A, E, R>(
8993
process.env.PATH = `${binDir}${pathDelimiter}${previousPath ?? ""}`;
9094
process.env.T3_FAKE_CLAUDE_OUTPUT = input.output;
9195

96+
if (input.rejectsNoSessionPersistence) {
97+
process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE = "1";
98+
} else {
99+
delete process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE;
100+
}
101+
92102
if (input.exitCode !== undefined) {
93103
process.env.T3_FAKE_CLAUDE_EXIT_CODE = String(input.exitCode);
94104
} else {
@@ -135,6 +145,13 @@ function withFakeClaudeEnv<A, E, R>(
135145
Effect.sync(() => {
136146
process.env.PATH = previousPath;
137147

148+
if (previousRejectsNoSessionPersistence === undefined) {
149+
delete process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE;
150+
} else {
151+
process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE =
152+
previousRejectsNoSessionPersistence;
153+
}
154+
138155
if (previousOutput === undefined) {
139156
delete process.env.T3_FAKE_CLAUDE_OUTPUT;
140157
} else {
@@ -188,6 +205,7 @@ function withFakeClaudeEnv<A, E, R>(
188205
const config = decodeClaudeSettings(input.claudeConfig ?? {});
189206
const textGeneration = yield* makeClaudeTextGeneration(
190207
config,
208+
Effect.succeed(input.cliVersion === undefined ? "2.1.316" : input.cliVersion),
191209
undefined,
192210
Effect.succeed(SYNTHETIC_CLAUDE_MODEL_CATALOG),
193211
);
@@ -320,6 +338,37 @@ it.layer(layerClaudeTextGenerationTest)("ClaudeTextGeneration", (it) => {
320338
}),
321339
);
322340

341+
it.effect.each([
342+
{ cliVersion: "2.0.63", rejectsNoSessionPersistence: false, label: "passes it to 2.0.63" },
343+
{ cliVersion: "2.0.62", rejectsNoSessionPersistence: true, label: "omits it for 2.0.62" },
344+
{
345+
cliVersion: null,
346+
rejectsNoSessionPersistence: true,
347+
label: "omits it for an unknown version",
348+
},
349+
])("--no-session-persistence $label", ({ cliVersion, rejectsNoSessionPersistence }) =>
350+
withFakeClaudeEnv(
351+
{
352+
output: JSON.stringify({ structured_output: { title: "Reconnect failures" } }),
353+
cliVersion,
354+
rejectsNoSessionPersistence,
355+
},
356+
(textGeneration) =>
357+
Effect.gen(function* () {
358+
const generated = yield* textGeneration.generateThreadTitle({
359+
cwd: process.cwd(),
360+
message: "Investigate reconnect failures",
361+
modelSelection: {
362+
instanceId: ProviderInstanceId.make("claudeAgent"),
363+
model: SYNTHETIC_CLAUDE_STANDARD_MODEL,
364+
},
365+
});
366+
367+
expect(generated.title).toBe("Reconnect failures");
368+
}),
369+
),
370+
);
371+
323372
it.effect.each([
324373
{ verbose: false, label: "normal" },
325374
{ verbose: true, label: "verbose" },

‎apps/server/src/textGeneration/ClaudeTextGeneration.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
getModelSelectionStringOptionValue,
1919
getProviderOptionDescriptors,
2020
} from "@t3tools/shared/model";
21+
import { compareSemverVersions } from "@t3tools/shared/semver";
2122
import {
2223
BUNDLED_CLAUDE_MODEL_CATALOG,
2324
type ClaudeModelCatalog,
@@ -49,6 +50,9 @@ const CLAUDE_INVESTIGATION_ALLOWED = [
4950
// Denies override allows; block git --output/-o because allowed trailing args can otherwise write anywhere.
5051
const CLAUDE_INVESTIGATION_DENIED = ["Bash(git * --output*)", "Bash(git * -o *)"].join(",");
5152

53+
// Claude Code before 2.0.63 rejects --no-session-persistence as an unknown option.
54+
const NO_SESSION_PERSISTENCE_MIN_VERSION = "2.0.63";
55+
5256
const ClaudeOutputEnvelope = Schema.Struct({
5357
structured_output: Schema.Unknown,
5458
});
@@ -79,6 +83,7 @@ function claudeErrorResult(stdout: string): string | undefined {
7983

8084
export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(function* (
8185
claudeSettings: ClaudeSettings,
86+
cliVersion: Effect.Effect<string | null>,
8287
environment?: NodeJS.ProcessEnv,
8388
modelCatalog: Effect.Effect<ClaudeModelCatalog> = Effect.succeed(BUNDLED_CLAUDE_MODEL_CATALOG),
8489
) {
@@ -193,6 +198,9 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
193198
)
194199
: cwd;
195200
const managedMcpConfig = yield* hasClaudeManagedMcpConfig();
201+
const version = yield* cliVersion;
202+
const supportsNoSessionPersistence =
203+
version !== null && compareSemverVersions(version, NO_SESSION_PERSISTENCE_MIN_VERSION) >= 0;
196204
const spawnCommand = yield* resolveSpawnCommand(
197205
claudeSettings.binaryPath || "claude",
198206
[
@@ -217,7 +225,7 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
217225
]
218226
: ["--tools", ""]),
219227
"--disable-slash-commands",
220-
"--no-session-persistence",
228+
...(supportsNoSessionPersistence ? ["--no-session-persistence"] : []),
221229
// managed-mcp.json already isolates servers and makes Claude reject this flag.
222230
...(managedMcpConfig ? [] : ["--strict-mcp-config"]),
223231
"--permission-mode",

‎apps/server/src/textGeneration/testing/ClaudeTextGeneration.fixture.mjs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ if (!argv.includes("--disable-slash-commands")) {
2525
if (!argv.includes("--strict-mcp-config")) {
2626
fail("text generation must not load configured MCP servers", 9);
2727
}
28-
if (!argv.includes("--no-session-persistence")) {
28+
if (process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE === "1") {
29+
if (argv.includes("--no-session-persistence")) {
30+
fail("error: unknown option '--no-session-persistence'", 1);
31+
}
32+
} else if (!argv.includes("--no-session-persistence")) {
2933
fail("text generation must not save a resumable session", 16);
3034
}
3135
const settingsIndex = argv.indexOf("--settings");

0 commit comments

Comments
 (0)