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, 22:15 UTC
fix(server): explain why /compact fails on providers without compaction (#33269)
Arkadev Banerjee committed
Nov 12, 2026 at 04:42 UTC
3f402e3ae410c89192c7f59751a65ba452de3ad8
4 files changed
+37
-2
apps/server/src/orchestration-v2/RunExecutionService.test.ts
+17
-1
@@ -2936,6 +2936,20 @@ it.effect("records a provider's input rejection at turn start in the terminal er
2936
}),
2937
);
2938
2939
+it.effect("tells the user why /compact failed on a provider without compaction", () =>
2940
+ Effect.gen(function* () {
2941
+ const { written } = yield* captureRootRunTermination({
2942
+ key: "start-failure:compact-unsupported",
2943
+ shouldFinalizeRun: () => Effect.succeed(true),
2944
+ events: () => Stream.never,
2945
+ afterStart: (closed) => Deferred.succeed(closed, undefined),
2946
+ messageText: "/compact",
2947
+ });
2948
+ const error = written.find((item) => item.type === "error");
2949
+ assert.include(error?.failure.message ?? "", "does not support /compact");
2950
+ }),
2951
+);
2952
+
2953
it.effect.each(["failure", "defect", "interrupt-failure", "ownership-lost"] as const)(
2954
"stops the live provider and background work before settling an ingestion %s",
2955
(failureMode) =>
@@ -3360,6 +3374,7 @@ function captureRootRunTermination(input: {
3374
>;
3375
readonly startTurn?: ProviderAdapter.ProviderAdapterV2SessionRuntime["startTurn"];
3376
readonly interruptTurn?: ProviderAdapter.ProviderAdapterV2SessionRuntime["interruptTurn"];
3377
+ readonly messageText?: string;
3378
readonly initialProviderTurnId?: ProviderTurnId | null;
3379
readonly onStartFailure?: (
3380
error: RunExecutionService.RunExecutionServiceV2Error,
@@ -3471,6 +3486,7 @@ function captureRootRunTermination(input: {
3486
appThread: rootAppThread(ids.threadId),
3487
providerSessionId: ProviderSessionId.make(`session:${input.key}`),
3488
session: {
3489
+ driver,
3490
events: Stream.empty,
3491
subscribeEvents: Effect.succeed({
3492
events:
@@ -3550,7 +3566,7 @@ function captureRootRunTermination(input: {
3566
: { hasWorkspaceMoved: input.hasWorkspaceMoved }),
3567
message: {
3568
messageId: MessageId.make(`message:${input.key}`),
3553
- text: "interrupt projection",
3569
+ text: input.messageText ?? "interrupt projection",
3570
attachments: [],
3571
createdBy: "user",
3572
creationSource: "web",
apps/server/src/orchestration-v2/RunExecutionService.ts
+4
-1
@@ -1861,7 +1861,10 @@ export const layer: Layer.Layer<
1861
threadId: input.run.threadId,
1862
providerThreadId: input.providerThread.id,
1863
runId: input.run.id,
1864
- cause: "This provider does not support context compaction.",
1864
+ cause: new ProviderAdapter.ProviderCompactionUnsupportedError({
1865
+ driver: input.session.driver,
1866
+ providerThreadId: input.providerThread.id,
1867
+ }),
1868
}),
1869
))
1870
: input.session.startTurn(turnInput);
packages/provider-core/src/server/ProviderAdapter.ts
+15
@@ -274,6 +274,21 @@ export class ProviderAdapterThreadInUseError extends Schema.TaggedError<Provider
274
}
275
}
276
277
+/**
278
+ * The user sent `/compact` to a driver whose session has no native compaction.
279
+ */
280
+export class ProviderCompactionUnsupportedError extends Schema.TaggedError<ProviderCompactionUnsupportedError>()(
281
+ "ProviderCompactionUnsupportedError",
282
+ {
283
+ driver: ProviderDriverKind,
284
+ providerThreadId: ProviderThreadId,
285
+ },
286
+) {
287
+ override get message(): string {
288
+ return "This provider does not support /compact. Start a new thread to continue with a fresh context.";
289
+ }
290
+}
291
+
292
export class ProviderAdapterEnsureThreadError extends Schema.TaggedError<ProviderAdapterEnsureThreadError>()(
293
"ProviderAdapterEnsureThreadError",
294
{
packages/provider-core/src/server/failure.ts
+1
@@ -116,6 +116,7 @@ function curatedCauseMessages(cause: unknown): {
116
case "CodexGoalObjectiveTooLongError":
117
case "ProviderSetupError":
118
case "ProviderAdapterThreadInUseError":
119
+ case "ProviderCompactionUnsupportedError":
120
return { known: stringField(cause, "message"), category: categoryMessage() };
121
case "CodexAppServerRequestError": {
122
// Only Codex's fixed-shape goal validation text is actionable and