@devries-cameron20 / t3code Mirror · read-only / commits / ddb14277ec
Fork 0

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, 08:30 UTC

fix(server): a Claude goal no longer shows as set after the CLI drops it on an error (#38199)

Co-authored-by: azhar <azhar.amir@amartha.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

azhar committed Nov 17, 2026 at 23:28 UTC ddb14277ec9cb3e4fba4bcc5dd9ab941aee9d136
2 files changed +65
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+57
@@ -24603,6 +24603,63 @@ describe("ClaudeAdapterV2 background wake turns", () => {
24603 ),
24604 ),
24605 );
24606 +
24607 + it.effect("drops a goal the CLI clears after an unrecoverable error", () =>
24608 + Effect.gen(function* () {
24609 + const harness = yield* makeWakeHarness;
24610 + const condition = "all tests pass";
24611 + yield* harness.runtime.startTurn(
24612 + makeClaudeTestTurnInput({
24613 + threadId: harness.threadId,
24614 + providerThread: {
24615 + ...harness.providerThread,
24616 + goal: { objective: condition, status: "active", checks: 1 },
24617 + },
24618 + now: yield* DateTime.now,
24619 + attemptId: RunAttemptId.make("goal-error-clear-attempt"),
24620 + text: "Continue.",
24621 + attachments: [],
24622 + }),
24623 + );
24624 + yield* Queue.offerAll(harness.sdkMessages, [
24625 + makeAssistantErrorFrame({
24626 + uuid: "goal-error-clear-api-error",
24627 + error: "invalid_request",
24628 + text: "Prompt is too long",
24629 + }),
24630 + claudeSdkFrame({
24631 + type: "system",
24632 + subtype: "informational",
24633 + content: `Goal cleared after an unrecoverable error (context limit reached): "${condition}". Run /goal again to continue.`,
24634 + level: "warning",
24635 + session_id: WAKE_NATIVE_SESSION,
24636 + uuid: "goal-error-clear-notice",
24637 + }),
24638 + makeResultFrame({
24639 + uuid: "goal-error-clear-result",
24640 + result: "Prompt is too long",
24641 + isError: true,
24642 + terminalReason: "prompt_too_long",
24643 + }),
24644 + ]);
24645 + const terminal = yield* Queue.take(harness.terminalReceipts);
24646 + assert.equal(terminal.status, "failed");
24647 + assert.isNull(
24648 + harness.events.findLast((event) => event.type === "provider_thread.updated")
24649 + ?.providerThread.goal,
24650 + );
24651 + }).pipe(
24652 + Effect.scoped,
24653 + Effect.provide(
24654 + Layer.mergeAll(
24655 + IdAllocator.layer,
24656 + McpProviderSessions.layer,
24657 + NodeServices.layer,
24658 + NodeCrypto.layer,
24659 + ),
24660 + ),
24661 + ),
24662 + );
24663 });
24664 });
24665
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+8
@@ -2546,6 +2546,14 @@ function nextClaudeGoal(
2546 current: OrchestrationV2ProviderGoal | null,
2547 message: SDKMessage,
2548 ): OrchestrationV2ProviderGoal | null | undefined {
2549 + // The CLI drops a goal on a context-limit, auth, or billing failure and reports it only here.
2550 + if (
2551 + message.type === "system" &&
2552 + message.subtype === "informational" &&
2553 + message.content.startsWith("Goal cleared after an unrecoverable error (")
2554 + ) {
2555 + return null;
2556 + }
2557 if (message.type === "assistant") {
2558 if (message.parent_tool_use_id !== null || message.message.model !== "<synthetic>") {
2559 return undefined;