The best way to control Claude Code, Codex and more from any computer or phone
fix(claude): Claude text generation stops saving throwaway transcripts (#28367)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Nov 1, 2026 at 16:05 UTC
638947e7db2726373e91956d5563117e22592026
4 files changed
+84
-15
apps/server/src/textGeneration/ClaudeTextGeneration.test.ts
+46
@@ -57,6 +57,7 @@ function makeFakeClaudeBinary(dir: string, lifecyclePort?: number) {
57
function withFakeClaudeEnv<A, E, R>(
58
input: {
59
output: string;
60
+ rejectsNoSessionPersistence?: boolean;
61
lifecyclePort?: number;
62
exitCode?: number;
63
stderr?: string;
@@ -75,6 +76,8 @@ function withFakeClaudeEnv<A, E, R>(
76
const binDir = yield* makeFakeClaudeBinary(tempDir, input.lifecyclePort);
77
const pathDelimiter = (yield* HostProcess.isWindows) ? ";" : ":";
78
const previousPath = process.env.PATH;
79
+ const previousRejectsNoSessionPersistence =
80
+ process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE;
81
const previousOutput = process.env.T3_FAKE_CLAUDE_OUTPUT;
82
const previousExitCode = process.env.T3_FAKE_CLAUDE_EXIT_CODE;
83
const previousStderr = process.env.T3_FAKE_CLAUDE_STDERR;
@@ -89,6 +92,12 @@ function withFakeClaudeEnv<A, E, R>(
92
process.env.PATH = `${binDir}${pathDelimiter}${previousPath ?? ""}`;
93
process.env.T3_FAKE_CLAUDE_OUTPUT = input.output;
94
95
+ if (input.rejectsNoSessionPersistence) {
96
+ process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE = "1";
97
+ } else {
98
+ delete process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE;
99
+ }
100
+
101
if (input.exitCode !== undefined) {
102
process.env.T3_FAKE_CLAUDE_EXIT_CODE = String(input.exitCode);
103
} else {
@@ -135,6 +144,13 @@ function withFakeClaudeEnv<A, E, R>(
144
Effect.sync(() => {
145
process.env.PATH = previousPath;
146
147
+ if (previousRejectsNoSessionPersistence === undefined) {
148
+ delete process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE;
149
+ } else {
150
+ process.env.T3_FAKE_CLAUDE_REJECTS_NO_SESSION_PERSISTENCE =
151
+ previousRejectsNoSessionPersistence;
152
+ }
153
+
154
if (previousOutput === undefined) {
155
delete process.env.T3_FAKE_CLAUDE_OUTPUT;
156
} else {
@@ -320,6 +336,28 @@ it.layer(layerClaudeTextGenerationTest)("ClaudeTextGeneration", (it) => {
336
}),
337
);
338
339
+ it.effect("retries without --no-session-persistence when the Claude CLI rejects it", () =>
340
+ withFakeClaudeEnv(
341
+ {
342
+ output: JSON.stringify({ structured_output: { title: "Reconnect failures" } }),
343
+ rejectsNoSessionPersistence: true,
344
+ },
345
+ (textGeneration) =>
346
+ Effect.gen(function* () {
347
+ const generated = yield* textGeneration.generateThreadTitle({
348
+ cwd: process.cwd(),
349
+ message: "Investigate reconnect failures",
350
+ modelSelection: {
351
+ instanceId: ProviderInstanceId.make("claudeAgent"),
352
+ model: SYNTHETIC_CLAUDE_STANDARD_MODEL,
353
+ },
354
+ });
355
+
356
+ expect(generated.title).toBe("Reconnect failures");
357
+ }),
358
+ ),
359
+ );
360
+
361
it.effect.each([
362
{ verbose: false, label: "normal" },
363
{ verbose: true, label: "verbose" },
@@ -430,6 +468,14 @@ it.layer(layerClaudeTextGenerationTest)("ClaudeTextGeneration", (it) => {
468
apiError,
469
],
470
["stderr when stdout has no error", "not json", wrapperNotice],
471
+ [
472
+ "a stdout error naming --no-session-persistence without retrying",
473
+ JSON.stringify({
474
+ is_error: true,
475
+ result: "error: unknown option '--no-session-persistence'",
476
+ }),
477
+ "error: unknown option '--no-session-persistence'",
478
+ ],
479
] as const)("reports %s when the Claude CLI fails", ([, output, expected]) =>
480
withFakeClaudeEnv({ output, stderr: wrapperNotice, exitCode: 1 }, (textGeneration) =>
481
Effect.gen(function* () {
apps/server/src/textGeneration/ClaudeTextGeneration.ts
+29
-15
@@ -49,6 +49,10 @@ const CLAUDE_INVESTIGATION_ALLOWED = [
49
// Denies override allows; block git --output/-o because allowed trailing args can otherwise write anywhere.
50
const CLAUDE_INVESTIGATION_DENIED = ["Bash(git * --output*)", "Bash(git * -o *)"].join(",");
51
52
+const NO_SESSION_PERSISTENCE = "--no-session-persistence";
53
+// Claude Code before 2.0.63 exits with this on stderr; those runs retry without the flag.
54
+const NO_SESSION_PERSISTENCE_REJECTED = `error: unknown option '${NO_SESSION_PERSISTENCE}'`;
55
+
56
const ClaudeOutputEnvelope = Schema.Struct({
57
structured_output: Schema.Unknown,
58
});
@@ -181,7 +185,9 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
185
"Failed to encode Claude CLI settings.",
186
);
187
184
- const runClaudeCommand = Effect.fn("runClaudeJson.runClaudeCommand")(function* () {
188
+ const runClaudeCommand = Effect.fn("runClaudeJson.runClaudeCommand")(function* (
189
+ noSessionPersistence: boolean,
190
+ ) {
191
const workingDirectory =
192
operation === "generateThreadTitle"
193
? yield* fileSystem
@@ -217,6 +223,7 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
223
]
224
: ["--tools", ""]),
225
"--disable-slash-commands",
226
+ ...(noSessionPersistence ? [NO_SESSION_PERSISTENCE] : []),
227
// managed-mcp.json already isolates servers and makes Claude reject this flag.
228
...(managedMcpConfig ? [] : ["--strict-mcp-config"]),
229
"--permission-mode",
@@ -255,25 +262,32 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
262
{ concurrency: "unbounded" },
263
);
264
258
- if (exitCode !== 0) {
265
+ return { stdout, stderr, exitCode };
266
+ });
267
+
268
+ const rawStdout = yield* runClaudeCommand(true).pipe(
269
+ Effect.filterOrElse(
270
+ (result) =>
271
+ result.exitCode === 0 || !result.stderr.includes(NO_SESSION_PERSISTENCE_REJECTED),
272
+ () => runClaudeCommand(false),
273
+ ),
274
+ Effect.flatMap(({ stdout, stderr, exitCode }) => {
275
+ if (exitCode === 0) return Effect.succeed(stdout);
276
const stderrDetail = stderr.trim();
277
const stdoutDetail = stdout.trim();
278
const detail =
279
claudeErrorResult(stdoutDetail) ??
280
(stderrDetail.length > 0 ? stderrDetail : stdoutDetail);
264
- return yield* new TextGenerationError({
265
- operation,
266
- detail:
267
- detail.length > 0
268
- ? `Claude CLI command failed: ${detail}`
269
- : `Claude CLI command failed with code ${exitCode}.`,
270
- });
271
- }
272
-
273
- return stdout;
274
- });
275
-
276
- const rawStdout = yield* runClaudeCommand().pipe(
281
+ return Effect.fail(
282
+ new TextGenerationError({
283
+ operation,
284
+ detail:
285
+ detail.length > 0
286
+ ? `Claude CLI command failed: ${detail}`
287
+ : `Claude CLI command failed with code ${exitCode}.`,
288
+ }),
289
+ );
290
+ }),
291
Effect.scoped,
292
Effect.timeoutOption(investigate?.timeoutMs ?? CLAUDE_TIMEOUT_MS),
293
Effect.flatMap(
apps/server/src/textGeneration/testing/ClaudeTextGeneration.fixture.mjs
+7
@@ -25,6 +25,13 @@ if (!argv.includes("--disable-slash-commands")) {
25
if (!argv.includes("--strict-mcp-config")) {
26
fail("text generation must not load configured MCP servers", 9);
27
}
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")) {
33
+ fail("text generation must not save a resumable session", 16);
34
+}
35
const settingsIndex = argv.indexOf("--settings");
36
if (settingsIndex === -1 || JSON.parse(argv[settingsIndex + 1]).disableAllHooks !== true) {
37
fail("text generation must disable hooks", 10);
docs/user/usage.md
+2
@@ -17,6 +17,8 @@ Select a model under **Breakdown** to see its trend, cache hit rate, and cost pe
17
18
Totals depend on the history available on each server. Grok turns without a saved completed-turn
19
record are missing from the totals.
20
+Text generation (thread titles, commit messages, PR text, branch names and review guides) is not in
21
+the totals for Codex or Claude Code 2.0.63 and newer, because those runs save no session history.
22
23
OpenCode reads its SQLite database and older JSON history. Antigravity reads local conversation
24
databases, including T3-managed profiles. Set `OPENCODE_DATA_DIR` or `ANTIGRAVITY_DATA_DIR` on the