@devries-cameron20 / t3code-1 / commits / 8c51e4ea7c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Claude append-system-prompt launch arguments reach the model (#20413)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Victor Vogel committed Oct 20, 2026 at 00:38 UTC 8c51e4ea7ceb7c3e4db1932c129b2c7e35e75f5f
5 files changed +387 -6
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+280
@@ -1211,6 +1211,156 @@ describe("ClaudeAdapterV2 Auto-accept edits", () => {
1211 );
1212 });
1213
1214 +describe("ClaudeAdapterV2 append-system-prompt-file launch argument", () => {
1215 + const startTurnWithLaunchArgs = Effect.fnUntraced(function* (launchArgs: string, cwd: string) {
1216 + const fileSystem = yield* FileSystem.FileSystem;
1217 + const opened: Array<ClaudeAdapterV2.ClaudeAgentSdkQueryOptions> = [];
1218 + const adapter = yield* ClaudeAdapterV2.makeClaudeAdapterV2({
1219 + instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
1220 + settings: { ...DEFAULT_CLAUDE_SETTINGS, launchArgs },
1221 + environment: {},
1222 + attachmentsDir: yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-append-" }),
1223 + fileSystem,
1224 + path: yield* Path.Path,
1225 + crypto: yield* Crypto.Crypto,
1226 + idAllocator: yield* IdAllocator.IdAllocatorV2,
1227 + queryRunner: {
1228 + allocateSessionId: Effect.succeed("native-thread-claude-append-file"),
1229 + open: (input) =>
1230 + Effect.sync(() => {
1231 + opened.push(input.options);
1232 + return {
1233 + messages: Stream.never,
1234 + offer: () => Effect.void,
1235 + setModel: () => Effect.void,
1236 + applyFlagSettings: () => Effect.void,
1237 + setPermissionMode: () => Effect.void,
1238 + backgroundTasks: () => Effect.succeed(false),
1239 + stopTask: () => Effect.void,
1240 + interrupt: Effect.void,
1241 + close: Effect.void,
1242 + };
1243 + }),
1244 + forkSession: () => Effect.die("unused"),
1245 + subagentLaunchToolUseId: () => Effect.succeed(null),
1246 + assertComplete: Effect.void,
1247 + },
1248 + });
1249 + const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
1250 + runtimeMode: "full-access",
1251 + interactionMode: "default",
1252 + cwd,
1253 + });
1254 + const threadId = ThreadId.make("thread-claude-append-file");
1255 + const runtime = yield* adapter.openSession({
1256 + threadId,
1257 + providerSessionId: ProviderSessionId.make("provider-session-claude-append-file"),
1258 + modelSelection: CLAUDE_TEST_MODEL_SELECTION,
1259 + runtimePolicy,
1260 + });
1261 + const providerThread = yield* runtime.ensureThread({
1262 + threadId,
1263 + modelSelection: CLAUDE_TEST_MODEL_SELECTION,
1264 + runtimePolicy,
1265 + });
1266 + const exit = yield* runtime
1267 + .startTurn(
1268 + makeClaudeTestTurnInput({
1269 + threadId,
1270 + providerThread,
1271 + now: yield* DateTime.now,
1272 + attemptId: RunAttemptId.make("attempt-claude-append-file"),
1273 + text: "What is the sentinel?",
1274 + attachments: [],
1275 + runtimePolicy,
1276 + }),
1277 + )
1278 + .pipe(Effect.exit);
1279 + return { exit, opened };
1280 + });
1281 +
1282 + const appendSystemPrompt = (options: ClaudeAdapterV2.ClaudeAgentSdkQueryOptions | undefined) =>
1283 + (options?.systemPrompt as { readonly append?: string } | undefined)?.append;
1284 +
1285 + it.effect("sends append launch arguments to Claude after the T3 instructions", () =>
1286 + Effect.scoped(
1287 + Effect.gen(function* () {
1288 + const fileSystem = yield* FileSystem.FileSystem;
1289 + const cwd = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-append-cwd-" });
1290 + yield* fileSystem.writeFileString(NodePath.join(cwd, "rules.md"), "File sentinel\n");
1291 + const plain = yield* startTurnWithLaunchArgs("", cwd);
1292 + const { exit, opened } = yield* startTurnWithLaunchArgs(
1293 + '--append-system-prompt "Inline sentinel" --append-system-prompt-file rules.md --system-prompt Replacement',
1294 + cwd,
1295 + );
1296 + assert.isTrue(Exit.isSuccess(exit));
1297 + assert.lengthOf(opened, 1);
1298 + assert.equal(
1299 + appendSystemPrompt(opened[0]),
1300 + `${appendSystemPrompt(plain.opened[0])}\n\nFile sentinel\n\nInline sentinel`,
1301 + );
1302 + assert.isUndefined(opened[0]!.extraArgs?.["append-system-prompt"]);
1303 + assert.isUndefined(opened[0]!.extraArgs?.["append-system-prompt-file"]);
1304 + assert.equal(opened[0]!.extraArgs?.["system-prompt"], "Replacement");
1305 + }).pipe(
1306 + Effect.provide(
1307 + Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
1308 + ),
1309 + ),
1310 + ),
1311 + );
1312 +
1313 + it.effect.each([
1314 + [
1315 + "--append-system-prompt-file missing.md",
1316 + (cwd: string) =>
1317 + new ClaudeAdapterV2.ClaudeAppendSystemPromptFileError({
1318 + path: NodePath.join(cwd, "missing.md"),
1319 + }).message,
1320 + ],
1321 + [
1322 + "--append-system-prompt-file",
1323 + () =>
1324 + new ClaudeAdapterV2.ClaudeAppendSystemPromptMissingValueError({
1325 + flag: "--append-system-prompt-file",
1326 + }).message,
1327 + ],
1328 + [
1329 + "--append-system-prompt-file=",
1330 + () =>
1331 + new ClaudeAdapterV2.ClaudeAppendSystemPromptMissingValueError({
1332 + flag: "--append-system-prompt-file",
1333 + }).message,
1334 + ],
1335 + [
1336 + "--append-system-prompt",
1337 + () =>
1338 + new ClaudeAdapterV2.ClaudeAppendSystemPromptMissingValueError({
1339 + flag: "--append-system-prompt",
1340 + }).message,
1341 + ],
1342 + ] as const)("fails the turn before opening Claude for %s", ([launchArgs, expectedMessage]) =>
1343 + Effect.scoped(
1344 + Effect.gen(function* () {
1345 + const fileSystem = yield* FileSystem.FileSystem;
1346 + const cwd = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-append-cwd-" });
1347 + const { exit, opened } = yield* startTurnWithLaunchArgs(launchArgs, cwd);
1348 + assert.lengthOf(opened, 0);
1349 + assert.isTrue(Exit.isFailure(exit));
1350 + if (!Exit.isFailure(exit)) return;
1351 + assert.equal(
1352 + makeProviderFailure({ cause: exit.cause, class: "provider_error" }).message,
1353 + expectedMessage(cwd),
1354 + );
1355 + }).pipe(
1356 + Effect.provide(
1357 + Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
1358 + ),
1359 + ),
1360 + ),
1361 + );
1362 +});
1363 +
1364 describe("ClaudeAdapterV2 approval cancellation", () => {
1365 it.effect("observes an approval signal that was already aborted", () =>
1366 Effect.gen(function* () {
@@ -13815,6 +13965,136 @@ describe("ClaudeAdapterV2 background wake turns", () => {
13965 ),
13966 );
13967
13968 + it.effect("keeps the live process when its replacement cannot read the append file", () =>
13969 + Effect.scoped(
13970 + Effect.gen(function* () {
13971 + const fileSystem = yield* FileSystem.FileSystem;
13972 + const cwd = yield* fileSystem.makeTempDirectoryScoped({
13973 + prefix: "t3-claude-append-replacement-",
13974 + });
13975 + const appendFile = NodePath.join(cwd, "rules.md");
13976 + yield* fileSystem.writeFileString(appendFile, "File sentinel\n");
13977 + const processQueues: Array<Queue.Queue<SDKMessage>> = [];
13978 + let closes = 0;
13979 + const firstTurnTerminal = yield* Deferred.make<void>();
13980 + const adapter = yield* ClaudeAdapterV2.makeClaudeAdapterV2({
13981 + instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
13982 + settings: {
13983 + ...DEFAULT_CLAUDE_SETTINGS,
13984 + launchArgs: "--append-system-prompt-file rules.md",
13985 + },
13986 + environment: {},
13987 + attachmentsDir: yield* fileSystem.makeTempDirectoryScoped({
13988 + prefix: "t3-claude-append-replacement-attachments-",
13989 + }),
13990 + fileSystem,
13991 + path: yield* Path.Path,
13992 + crypto: yield* Crypto.Crypto,
13993 + idAllocator: yield* IdAllocator.IdAllocatorV2,
13994 + continuationRequests: { offer: () => Effect.void },
13995 + queryRunner: {
13996 + allocateSessionId: Effect.succeed(WAKE_NATIVE_SESSION),
13997 + open: () =>
13998 + Effect.gen(function* () {
13999 + const sdkMessages = yield* Queue.unbounded<SDKMessage>();
14000 + processQueues.push(sdkMessages);
14001 + return {
14002 + messages: Stream.fromQueue(sdkMessages),
14003 + offer: () => Effect.void,
14004 + setModel: () => Effect.void,
14005 + applyFlagSettings: () => Effect.void,
14006 + setPermissionMode: () => Effect.void,
14007 + backgroundTasks: () => Effect.succeed(false),
14008 + stopTask: () => Effect.void,
14009 + interrupt: Effect.void,
14010 + close: Effect.sync(() => {
14011 + closes += 1;
14012 + }).pipe(Effect.andThen(Queue.shutdown(sdkMessages))),
14013 + };
14014 + }),
14015 + forkSession: () => Effect.die("unused forkSession"),
14016 + subagentLaunchToolUseId: () => Effect.succeed(null),
14017 + assertComplete: Effect.void,
14018 + },
14019 + });
14020 + const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
14021 + runtimeMode: "full-access",
14022 + interactionMode: "default",
14023 + cwd,
14024 + });
14025 + const threadId = ThreadId.make("thread-claude-append-replacement");
14026 + const runtime = yield* adapter.openSession({
14027 + threadId,
14028 + providerSessionId: ProviderSessionId.make("provider-session-claude-append-replacement"),
14029 + modelSelection: CLAUDE_TEST_MODEL_SELECTION,
14030 + runtimePolicy,
14031 + });
14032 + const providerThread = yield* runtime.ensureThread({
14033 + threadId,
14034 + modelSelection: CLAUDE_TEST_MODEL_SELECTION,
14035 + runtimePolicy,
14036 + });
14037 + yield* runtime.events.pipe(
14038 + Stream.runForEach((event) =>
14039 + event.type === "turn.terminal"
14040 + ? Deferred.succeed(firstTurnTerminal, undefined)
14041 + : Effect.void,
14042 + ),
14043 + Effect.forkScoped,
14044 + );
14045 + const now = yield* DateTime.now;
14046 +
14047 + yield* runtime.startTurn(
14048 + makeClaudeTestTurnInput({
14049 + threadId,
14050 + providerThread,
14051 + now,
14052 + attemptId: RunAttemptId.make("attempt-claude-append-replacement-a"),
14053 + text: "What is the sentinel?",
14054 + attachments: [],
14055 + runtimePolicy,
14056 + }),
14057 + );
14058 + yield* Queue.offer(
14059 + processQueues[0]!,
14060 + makeResultFrame({
14061 + uuid: "00000000-0000-4000-8000-000000000a01",
14062 + result: "File sentinel",
14063 + }),
14064 + );
14065 + yield* Deferred.await(firstTurnTerminal);
14066 +
14067 + yield* fileSystem.remove(appendFile);
14068 + // A thinking change cannot apply live, so this turn must replace the process.
14069 + const refused = yield* runtime
14070 + .startTurn(
14071 + makeClaudeTestTurnInput({
14072 + threadId,
14073 + providerThread: { ...providerThread, status: "active" },
14074 + now,
14075 + attemptId: RunAttemptId.make("attempt-claude-append-replacement-b"),
14076 + text: "Switch model.",
14077 + attachments: [],
14078 + providerTurnOrdinal: 2,
14079 + modelSelection: CLAUDE_TEST_RESTART_MODEL_SELECTION,
14080 + runtimePolicy,
14081 + }),
14082 + )
14083 + .pipe(Effect.flip);
14084 + assert.equal(
14085 + makeProviderFailure({ cause: refused, class: "provider_error" }).message,
14086 + new ClaudeAdapterV2.ClaudeAppendSystemPromptFileError({ path: appendFile }).message,
14087 + );
14088 + assert.lengthOf(processQueues, 1);
14089 + assert.equal(closes, 0);
14090 + }).pipe(
14091 + Effect.provide(
14092 + Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
14093 + ),
14094 + ),
14095 + ),
14096 + );
14097 +
14098 it.effect(
14099 "keeps the process and its roster when a model change meets a running background shell",
14100 () =>
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+80 -2
@@ -517,6 +517,27 @@ export class ClaudeBackgroundWorkBlocksQueryReplacementError extends Schema.Tagg
517 }
518 }
519
520 +export class ClaudeAppendSystemPromptFileError extends Schema.TaggedError<ClaudeAppendSystemPromptFileError>()(
521 + "ClaudeAppendSystemPromptFileError",
522 + {
523 + path: Schema.String,
524 + cause: Schema.optional(Schema.Defect()),
525 + },
526 +) {
527 + override get message(): string {
528 + return `Claude could not read the --append-system-prompt-file launch argument at ${this.path}. Fix the path in the Claude launch arguments, then send the message again.`;
529 + }
530 +}
531 +
532 +export class ClaudeAppendSystemPromptMissingValueError extends Schema.TaggedError<ClaudeAppendSystemPromptMissingValueError>()(
533 + "ClaudeAppendSystemPromptMissingValueError",
534 + { flag: Schema.Literals(["--append-system-prompt", "--append-system-prompt-file"]) },
535 +) {
536 + override get message(): string {
537 + return `The ${this.flag} launch argument has no ${this.flag === "--append-system-prompt" ? "text" : "file path"}. Add it after the flag in the Claude launch arguments, then send the message again.`;
538 + }
539 +}
540 +
541 export interface ClaudeAgentSdkQueryRunnerShape {
542 readonly allocateSessionId: Effect.Effect<string, ClaudeAgentSdkQueryRunnerError>;
543 readonly open: (
@@ -1238,13 +1259,23 @@ export function makeClaudeQueryOptions(input: {
1259 readonly onUserDialog?: ClaudeQueryOptions["onUserDialog"];
1260 readonly supportedDialogKinds?: ClaudeQueryOptions["supportedDialogKinds"];
1261 readonly allowDangerouslySkipPermissions?: boolean;
1262 + readonly appendSystemPromptFileText?: string;
1263 }): ClaudeAgentSdkQueryOptions {
1264 const compiledSelection = compileClaudeModelSelection(input.modelSelection);
1265 const {
1266 "permission-mode": launchArgPermissionMode,
1267 "dangerously-skip-permissions": launchArgSkipPermissions,
1268 + "append-system-prompt": launchArgAppendSystemPrompt,
1269 + "append-system-prompt-file": _launchArgAppendSystemPromptFile,
1270 ...extraArgs
1271 } = input.settings === undefined ? {} : parseCliArgs(input.settings.launchArgs).flags;
1272 + // Claude Code overwrites its CLI append text with the SDK's initialize
1273 + // appendSystemPrompt, so launch-argument text has to travel in that value.
1274 + // The CLI puts file text before inline text and trims one trailing newline.
1275 + const launchAppendSystemPrompt = [
1276 + input.appendSystemPromptFileText?.replace(/\r?\n$/, ""),
1277 + launchArgAppendSystemPrompt,
1278 + ].filter((text): text is string => typeof text === "string" && text.length > 0);
1279 const requestThinkingSummaries =
1280 compiledSelection.settings.alwaysThinkingEnabled !== false &&
1281 extraArgs["thinking-display"] !== "omitted";
@@ -1320,9 +1351,11 @@ export function makeClaudeQueryOptions(input: {
1351 systemPrompt: {
1352 type: "preset" as const,
1353 preset: "claude_code" as const,
1323 - append:
1354 + append: [
1355 buildRuntimeInstructions({ harness: "Claude Code" }) +
1325 - (input.mcpServers === undefined ? "" : T3_CODE_ORCHESTRATION_INSTRUCTIONS),
1356 + (input.mcpServers === undefined ? "" : T3_CODE_ORCHESTRATION_INSTRUCTIONS),
1357 + ...launchAppendSystemPrompt,
1358 + ].join("\n\n"),
1359 },
1360 ...(Object.keys(extraArgs).length === 0 ? {} : { extraArgs }),
1361 };
@@ -1335,6 +1368,43 @@ export function makeClaudeQueryOptions(input: {
1368 return input.cwd === null ? withDirectories : { ...withDirectories, cwd: input.cwd };
1369 }
1370
1371 +/**
1372 + * Checks the append launch arguments the way the Claude CLI would and reads
1373 + * the file relative to the process cwd. makeClaudeQueryOptions folds these
1374 + * flags out of extraArgs, so a value the CLI would have rejected has to be
1375 + * rejected here or it silently disappears.
1376 + */
1377 +const readClaudeAppendSystemPromptFile = Effect.fnUntraced(function* (input: {
1378 + readonly settings: ClaudeSettings | undefined;
1379 + readonly cwd: string | null;
1380 + readonly fileSystem: FileSystem.FileSystem;
1381 + readonly path: Path.Path;
1382 +}) {
1383 + if (input.settings === undefined) return undefined;
1384 + const flags = parseCliArgs(input.settings.launchArgs).flags;
1385 + // parseCliArgs gives null for a flag with no following value. An explicit
1386 + // `--append-system-prompt ""` is a value the CLI accepts, so it stays.
1387 + if (flags["append-system-prompt"] === null) {
1388 + return yield* new ClaudeAppendSystemPromptMissingValueError({
1389 + flag: "--append-system-prompt",
1390 + });
1391 + }
1392 + const file = flags["append-system-prompt-file"];
1393 + if (file === undefined) return undefined;
1394 + // `--append-system-prompt-file=` is "" and names no file either.
1395 + if (file === null || file === "") {
1396 + return yield* new ClaudeAppendSystemPromptMissingValueError({
1397 + flag: "--append-system-prompt-file",
1398 + });
1399 + }
1400 + const filePath = input.path.resolve(input.cwd ?? ".", file);
1401 + return yield* input.fileSystem
1402 + .readFileString(filePath)
1403 + .pipe(
1404 + Effect.mapError((cause) => new ClaudeAppendSystemPromptFileError({ path: filePath, cause })),
1405 + );
1406 +});
1407 +
1408 export const CLAUDE_T3_MCP_TOOL_WILDCARD = "mcp__t3-code__*";
1409
1410 // Must stay in sync with the Tool.Readonly annotations on OrchestratorToolkit;
@@ -9047,6 +9117,13 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9117 return yield* new ClaudeBackgroundWorkBlocksQueryReplacementError();
9118 }
9119
9120 + // Read before closing the live process so a bad path leaves it running.
9121 + const appendSystemPromptFileText = yield* readClaudeAppendSystemPromptFile({
9122 + settings: adapterOptions.settings,
9123 + cwd: turnInput.runtimePolicy.cwd,
9124 + fileSystem,
9125 + path,
9126 + });
9127 const closedExistingNativeThreadId = existing !== null ? existing.nativeThreadId : null;
9128 if (existing !== null) {
9129 yield* existing.query.close.pipe(Effect.ignore);
@@ -9091,6 +9168,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9168 canUseTool,
9169 onUserDialog,
9170 supportedDialogKinds: ["resume_return"],
9171 + ...(appendSystemPromptFileText === undefined ? {} : { appendSystemPromptFileText }),
9172 });
9173 const querySession = yield* queryRunner
9174 .open({
apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+11 -2
@@ -66,9 +66,18 @@ export class ProviderTurnStartError extends Schema.TaggedError<ProviderTurnStart
66
67 const isProviderTurnStartError = Schema.is(ProviderTurnStartError);
68
69 -/** Claude refuses to replace a process running background work before it reads the prompt. */
69 +/**
70 + * Claude refuses these before it reads the prompt: replacing a process running background work,
71 + * or launch arguments whose appended system prompt cannot be read.
72 + */
73 +const PROMPT_REFUSAL_TAGS = [
74 + "ClaudeBackgroundWorkBlocksQueryReplacementError",
75 + "ClaudeAppendSystemPromptFileError",
76 + "ClaudeAppendSystemPromptMissingValueError",
77 +] as const;
78 +
79 const refusedBeforePrompt = (error: unknown): boolean =>
71 - Predicate.isTagged(error, "ClaudeBackgroundWorkBlocksQueryReplacementError") ||
80 + PROMPT_REFUSAL_TAGS.some((tag) => Predicate.isTagged(error, tag)) ||
81 (Predicate.hasProperty(error, "cause") && refusedBeforePrompt(error.cause));
82
83 export interface ProviderTurnStartServiceV2Shape {
apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
+14 -2
@@ -35,6 +35,8 @@ import * as SqlClient from "effect/sql/SqlClient";
35 import * as SqlitePersistence from "../../persistence/Sqlite.ts";
36 import { CommandPolicyCapabilityUnsupportedError } from "../CommandPolicy.ts";
37 import {
38 + ClaudeAppendSystemPromptFileError,
39 + ClaudeAppendSystemPromptMissingValueError,
40 ClaudeBackgroundWorkBlocksQueryReplacementError,
41 ClaudeProviderCapabilitiesV2,
42 } from "../Adapters/ClaudeAdapterV2.ts";
@@ -103,6 +105,7 @@ function makeTestAdapter(input: {
105 readonly injectedHistory?: Ref.Ref<ReadonlyArray<unknown>>;
106 readonly failStartOnce?: Ref.Ref<boolean>;
107 readonly refuseStarts?: Ref.Ref<number>;
108 + readonly refusalCause?: unknown;
109 readonly failInjectionOnce?: Ref.Ref<boolean>;
110 readonly nativeThreadGeneration?: Ref.Ref<number>;
111 readonly failResume?: boolean;
@@ -235,7 +238,8 @@ function makeTestAdapter(input: {
238 threadId: turnInput.threadId,
239 providerThreadId: turnInput.providerThread.id,
240 runId: turnInput.runId,
238 - cause: new ClaudeBackgroundWorkBlocksQueryReplacementError(),
241 + cause:
242 + input.refusalCause ?? new ClaudeBackgroundWorkBlocksQueryReplacementError(),
243 });
244 yield* Effect.yieldNow;
245 yield* Ref.update(input.capturedTurns, (turns) => [
@@ -1196,7 +1200,14 @@ describe("orchestration v2 provider switching", () => {
1200 ),
1201 );
1202
1199 - it.live("keeps the native session after turns refused before reaching the provider", () =>
1203 + it.live.each([
1204 + ["background work", new ClaudeBackgroundWorkBlocksQueryReplacementError()],
1205 + ["an unreadable append file", new ClaudeAppendSystemPromptFileError({ path: "missing.md" })],
1206 + [
1207 + "a missing append value",
1208 + new ClaudeAppendSystemPromptMissingValueError({ flag: "--append-system-prompt" }),
1209 + ],
1210 + ] as const)("keeps the native session after turns refused for %s", ([, refusalCause]) =>
1211 Effect.scoped(
1212 Effect.gen(function* () {
1213 const cwd = yield* checkpointWorkspace("refused-start-keeps-native");
@@ -1212,6 +1223,7 @@ describe("orchestration v2 provider switching", () => {
1223 responseByRunOrdinal: {},
1224 capturedTurns,
1225 refuseStarts,
1226 + refusalCause,
1227 nativeThreadGeneration: generation,
1228 }),
1229 ]);
packages/provider-core/src/server/failure.ts
+2
@@ -74,6 +74,8 @@ function causeMessage(cause: unknown): string | undefined {
74 case "ContextHandoffBudgetError":
75 return new ContextHandoffBudgetError().message;
76 case "ClaudeBackgroundWorkBlocksQueryReplacementError":
77 + case "ClaudeAppendSystemPromptFileError":
78 + case "ClaudeAppendSystemPromptMissingValueError":
79 case "CursorModelUnavailableError":
80 return stringField(cause, "message");
81 case "ContextHandoffDeliveryUncertainError":