Skip to content

Commit d19040a

Browse files
t3dotggclaude
andcommitted
fix(server): an unanswered Codex goal pause no longer keeps the run open
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1ec107f commit d19040a

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6369,6 +6369,71 @@ describe("CodexAdapterV2 post-settle continuation", () => {
63696369
),
63706370
);
63716371

6372+
it.effect("settles the run when Codex never answers the expiry pause", () =>
6373+
Effect.gen(function* () {
6374+
const prompt = "Keep going";
6375+
const transcript = makeCodexReplayTranscript({
6376+
scenario: "goal-expiry-pause-unanswered",
6377+
entries: [
6378+
...codexReplayPreamble({ nativeThreadId, nativeTurnId: "goal-turn", prompt }),
6379+
notification("goal active", "thread/goal/updated", {
6380+
threadId: nativeThreadId,
6381+
turnId: "goal-turn",
6382+
goal: codexGoal("active", 10),
6383+
}),
6384+
notification("turn done", "turn/completed", {
6385+
threadId: nativeThreadId,
6386+
turn: makeCodexReplayTurn({ id: "goal-turn", status: "completed" }),
6387+
}),
6388+
notification("goal accounted", "thread/goal/updated", {
6389+
threadId: nativeThreadId,
6390+
turnId: null,
6391+
goal: codexGoal("active", 11),
6392+
}),
6393+
{
6394+
type: "expect_outbound",
6395+
label: "pause",
6396+
frame: {
6397+
id: 4,
6398+
method: "thread/goal/set",
6399+
params: { threadId: nativeThreadId, status: "paused" },
6400+
},
6401+
},
6402+
],
6403+
});
6404+
const harness = yield* makeCodexReplayHarness(transcript);
6405+
yield* harness.runtime.startTurn(
6406+
makeCodexTestTurnInput({
6407+
threadId: harness.threadId,
6408+
providerThread: harness.providerThread,
6409+
now: yield* DateTime.now,
6410+
attemptId: RunAttemptId.make("goal-unanswered-attempt"),
6411+
text: prompt,
6412+
}),
6413+
);
6414+
yield* harness.until(() =>
6415+
harness.events.some(
6416+
(event) =>
6417+
event.type === "provider_thread.updated" &&
6418+
event.providerThread.goal?.tokensUsed === 11,
6419+
),
6420+
);
6421+
yield* TestClock.adjust("5 seconds");
6422+
yield* TestClock.adjust("10 seconds");
6423+
yield* harness.firstTerminal;
6424+
6425+
assert.deepEqual(
6426+
harness.terminalEvents().map((event) => event.status),
6427+
["completed"],
6428+
);
6429+
}).pipe(
6430+
Effect.scoped,
6431+
Effect.provide(
6432+
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
6433+
),
6434+
),
6435+
);
6436+
63726437
it.effect("pauses an active goal before Stop interrupts its turn", () =>
63736438
Effect.gen(function* () {
63746439
const prompt = "Keep going";

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5721,6 +5721,8 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
57215721
yield* client
57225722
.request("thread/goal/set", { threadId: nativeThreadId, status: "paused" })
57235723
.pipe(
5724+
// The hold is already claimed, so an unanswered pause must not keep the run open.
5725+
Effect.timeout("10 seconds"),
57245726
Effect.flatMap(({ goal }) => {
57255727
goalsByNativeThread.set(nativeThreadId, providerGoalFromCodex(goal));
57265728
return emitGoalUpdate(nativeThreadId);

0 commit comments

Comments
 (0)