The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 21:00 UTC
fix(server): a Claude resume rejected before the prompt keeps the native session (#34762)
Julius Marminge committed
Nov 11, 2026 at 21:43 UTC
ddc4f576023b3bf7ead6c831510c1d72316bb1c2
3 files changed
+22
-2
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+4
-1
@@ -244,6 +244,9 @@ import {
244
} from "@t3tools/provider-core/server/subagentProjection";
245
246
export const CLAUDE_PROVIDER = ProviderDriverKind.make("claudeAgent");
247
+/** The query exited before the turn attached, so the prompt was never offered. */
248
+export const CLAUDE_QUERY_ENDED_BEFORE_TURN_DETAIL =
249
+ "Claude provider query ended before the turn could start.";
250
const CLAUDE_AGENT_SDK_QUERY_PROTOCOL = "claude-agent-sdk.query" as const;
251
252
interface ClaudeCacheCreation {
@@ -12127,7 +12130,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
12130
yield* Ref.update(activeTurn, (current) => (current === context ? null : current));
12131
return yield* new ProviderAdapter.ProviderAdapterProtocolError({
12132
driver: CLAUDE_PROVIDER,
12130
- detail: "Claude provider query ended before the turn could start.",
12133
+ detail: CLAUDE_QUERY_ENDED_BEFORE_TURN_DETAIL,
12134
});
12135
}
12136
if (
apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+10
-1
@@ -26,6 +26,10 @@ import * as Predicate from "effect/Predicate";
26
import * as Schema from "effect/Schema";
27
28
import * as ServerConfig from "../config.ts";
29
+import {
30
+ CLAUDE_PROVIDER,
31
+ CLAUDE_QUERY_ENDED_BEFORE_TURN_DETAIL,
32
+} from "./Adapters/ClaudeAdapterV2.ts";
33
import { withWorkspaceLease } from "../workspace/workspaceLease.ts";
34
import * as GitWorkflowService from "../git/GitWorkflowService.ts";
35
import * as ProjectService from "../project/ProjectService.ts";
@@ -95,6 +99,7 @@ class WorktreeRecreateNoBaseError extends Schema.TaggedError<WorktreeRecreateNoB
99
}
100
101
const isProviderTurnStartError = Schema.is(ProviderTurnStartError);
102
+const isProviderAdapterProtocolError = Schema.is(ProviderAdapter.ProviderAdapterProtocolError);
103
const isProviderAdapterOpenSessionError = Schema.is(
104
ProviderAdapter.ProviderAdapterOpenSessionError,
105
);
@@ -102,7 +107,8 @@ const isProviderAdapterOpenSessionError = Schema.is(
107
/**
108
* Claude refuses these before it reads the prompt: replacing a process running background work,
109
* launch arguments whose appended system prompt or settings cannot be read, or MCP registration
105
- * that never answers while the query opens.
110
+ * that never answers while the query opens. A query that ends before the turn attaches (such as a
111
+ * rejected resume point) never received the prompt either.
112
*/
113
const PROMPT_REFUSAL_TAGS = [
114
"ClaudeBackgroundWorkBlocksQueryReplacementError",
@@ -114,6 +120,9 @@ const PROMPT_REFUSAL_TAGS = [
120
121
const refusedBeforePrompt = (error: unknown): boolean =>
122
PROMPT_REFUSAL_TAGS.some((tag) => Predicate.isTagged(error, tag)) ||
123
+ (isProviderAdapterProtocolError(error) &&
124
+ error.driver === CLAUDE_PROVIDER &&
125
+ error.detail === CLAUDE_QUERY_ENDED_BEFORE_TURN_DETAIL) ||
126
(Predicate.hasProperty(error, "cause") && refusedBeforePrompt(error.cause));
127
128
const startFailureMessage = (error: Error): string => {
apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
+8
@@ -1504,6 +1504,14 @@ describe("orchestration v2 provider switching", () => {
1504
cause: new ClaudeMcpRegistrationTimeoutError(),
1505
}),
1506
],
1507
+ // Claude Code ends the query with "No message found with message.uuid" before the prompt.
1508
+ [
1509
+ "a resume point Claude rejects",
1510
+ new ProviderAdapter.ProviderAdapterProtocolError({
1511
+ driver: CLAUDE_DRIVER,
1512
+ detail: "Claude provider query ended before the turn could start.",
1513
+ }),
1514
+ ],
1515
] as const)("keeps the native session after turns refused for %s", ([, refusalCause]) =>
1516
Effect.scoped(
1517
Effect.gen(function* () {