@devries-cameron20 / t3code Mirror · read-only / commits / f1919eb1e2
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, 11:00 UTC

fix(server): Codex prompt suggestions no longer imitate delegated task notices (#37292)

Julius Marminge committed Nov 15, 2026 at 09:09 UTC f1919eb1e297cab345ac6785e5a6a26332a2b0bb
2 files changed +113 -1
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+111
@@ -2515,6 +2515,117 @@ describe("CodexAdapterV2 post-settle continuation", () => {
2515 ),
2516 );
2517
2518 + it.effect("does not suggest a sample that imitates a delegated task wake", () =>
2519 + Effect.gen(function* () {
2520 + const nativeThreadId = "suggest-wake-thread";
2521 + const prompt = "Delegate the README check.";
2522 + const first = codexReplayPreamble({ nativeThreadId, nativeTurnId: "wake-turn-1", prompt });
2523 + const second = codexReplayPreamble({ nativeThreadId, nativeTurnId: "wake-turn-2", prompt });
2524 + const completedAndSampled = (
2525 + nativeTurnId: string,
2526 + id: number,
2527 + text: string,
2528 + ): Array<CodexReplay.CodexAppServerReplayEntry> => [
2529 + {
2530 + type: "emit_inbound",
2531 + label: `${nativeTurnId} completed`,
2532 + frame: {
2533 + method: "turn/completed",
2534 + params: {
2535 + threadId: nativeThreadId,
2536 + turn: makeCodexReplayTurn({ id: nativeTurnId, status: "completed" }),
2537 + },
2538 + },
2539 + },
2540 + {
2541 + type: "expect_outbound",
2542 + label: `${nativeTurnId} thread/sample`,
2543 + frame: {
2544 + id,
2545 + method: "thread/sample",
2546 + params: {
2547 + threadId: nativeThreadId,
2548 + expectedTurnId: nativeTurnId,
2549 + prompt: CodexAdapterV2.CODEX_PROMPT_SUGGESTION_PROMPT,
2550 + effort: "low",
2551 + },
2552 + },
2553 + },
2554 + {
2555 + type: "emit_inbound",
2556 + label: `${nativeTurnId} thread/sample`,
2557 + frame: { id, result: { sourceTurnId: nativeTurnId, text } },
2558 + },
2559 + ];
2560 + // The second turn's ordinary suggestion is the barrier for the first turn's sample.
2561 + const firstSampleAnswered = yield* Deferred.make<void>();
2562 + const harness = yield* makeCodexReplayHarness(
2563 + makeCodexReplayTranscript({
2564 + scenario: "prompt-suggestion-delegated-wake",
2565 + entries: [
2566 + ...first,
2567 + ...completedAndSampled(
2568 + "wake-turn-1",
2569 + 4,
2570 + "Delegated task (Read README) [completed]: Here is the first line of the README.",
2571 + ),
2572 + ...second.slice(5, 7).map((entry) => withReplayRequestId(entry, 5)),
2573 + ...completedAndSampled("wake-turn-2", 6, "add tests for subtract"),
2574 + ],
2575 + }),
2576 + undefined,
2577 + undefined,
2578 + undefined,
2579 + (entry) =>
2580 + entry.label === "wake-turn-1 thread/sample"
2581 + ? Deferred.succeed(firstSampleAnswered, undefined).pipe(Effect.asVoid)
2582 + : Effect.void,
2583 + undefined,
2584 + Effect.succeed(true),
2585 + );
2586 + const turn = makeCodexTestTurnInput({
2587 + threadId: harness.threadId,
2588 + providerThread: harness.providerThread,
2589 + now: yield* DateTime.now,
2590 + attemptId: RunAttemptId.make("wake-attempt-1"),
2591 + text: prompt,
2592 + });
2593 + yield* harness.runtime.startTurn(turn);
2594 + yield* harness.awaitTerminal(1);
2595 + yield* Deferred.await(firstSampleAnswered);
2596 + yield* harness.runtime.startTurn({
2597 + ...turn,
2598 + runId: RunId.make("wake-run-2"),
2599 + attemptId: RunAttemptId.make("wake-attempt-2"),
2600 + rootNodeId: NodeId.make("wake-root-2"),
2601 + runOrdinal: 2,
2602 + providerTurnOrdinal: 2,
2603 + });
2604 + yield* harness.until(() =>
2605 + harness.events.some(
2606 + (event) =>
2607 + event.type === "prompt_suggestion.updated" && event.text === "add tests for subtract",
2608 + ),
2609 + );
2610 + assert.deepEqual(
2611 + harness.events.flatMap((event) =>
2612 + event.type === "prompt_suggestion.updated" ? [event.text] : [],
2613 + ),
2614 + ["add tests for subtract"],
2615 + );
2616 + }).pipe(
2617 + Effect.scoped,
2618 + Effect.provide(
2619 + Layer.mergeAll(
2620 + IdAllocator.layer,
2621 + McpProviderSessions.layer,
2622 + NodeServices.layer,
2623 + NodeCrypto.layer,
2624 + ),
2625 + ),
2626 + ),
2627 + );
2628 +
2629 it.effect("samples a next-prompt suggestion after a completed root turn", () =>
2630 Effect.gen(function* () {
2631 const nativeThreadId = "suggest-thread";
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+2 -1
@@ -2283,7 +2283,8 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
2283 });
2284 const suggestion =
2285 (yield* decodeCodexThreadSampleResponse(response)).text?.trim() ?? "";
2286 - if (suggestion.length === 0) return;
2286 + // Delegated completion wakes arrive as user input, so samples can imitate one.
2287 + if (suggestion.length === 0 || suggestion.startsWith("Delegated task")) return;
2288 yield* emitProviderEvent({
2289 type: "prompt_suggestion.updated",
2290 driver: CODEX_PROVIDER,