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, 17:15 UTC
fix(server): Codex question answers keep their native question id (#35886)
Julius Marminge committed
Nov 12, 2026 at 19:41 UTC
f39d38bcc10ae3a31169ebd34a3d1664d491e716
2 files changed
+104
-11
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+89
@@ -2356,6 +2356,95 @@ describe("CodexAdapterV2 post-settle continuation", () => {
2356
),
2357
);
2358
2359
+ it.effect("returns a Codex question's answer under its native question id", () =>
2360
+ Effect.scoped(
2361
+ Effect.gen(function* () {
2362
+ const nativeThreadId = "question-id-thread";
2363
+ const nativeTurnId = "question-id-turn";
2364
+ const transcript = makeCodexReplayTranscript({
2365
+ scenario: "codex-question-native-id",
2366
+ entries: [
2367
+ ...codexReplayPreamble({ nativeThreadId, nativeTurnId, prompt: "Pick one." }),
2368
+ {
2369
+ type: "emit_inbound",
2370
+ label: "question",
2371
+ frame: {
2372
+ id: 100,
2373
+ method: "item/tool/requestUserInput",
2374
+ params: {
2375
+ threadId: nativeThreadId,
2376
+ turnId: nativeTurnId,
2377
+ itemId: "question-id-item",
2378
+ isBlocking: true,
2379
+ questions: [
2380
+ {
2381
+ id: " choice ",
2382
+ header: "Choice",
2383
+ question: "Which option?",
2384
+ options: [{ label: "A", description: "Option A" }],
2385
+ },
2386
+ ],
2387
+ },
2388
+ },
2389
+ },
2390
+ {
2391
+ type: "expect_outbound",
2392
+ label: "answer",
2393
+ frame: { id: 100, result: { answers: { " choice ": { answers: ["A"] } } } },
2394
+ },
2395
+ {
2396
+ type: "emit_inbound",
2397
+ label: "complete",
2398
+ frame: {
2399
+ method: "turn/completed",
2400
+ params: {
2401
+ threadId: nativeThreadId,
2402
+ turn: makeCodexReplayTurn({ id: nativeTurnId, status: "completed" }),
2403
+ },
2404
+ },
2405
+ },
2406
+ ],
2407
+ });
2408
+ const harness = yield* makeCodexReplayHarness(transcript);
2409
+ yield* harness.runtime.startTurn(
2410
+ makeCodexTestTurnInput({
2411
+ threadId: harness.threadId,
2412
+ providerThread: harness.providerThread,
2413
+ now: yield* DateTime.now,
2414
+ attemptId: RunAttemptId.make("question-id-attempt"),
2415
+ text: "Pick one.",
2416
+ }),
2417
+ );
2418
+ const questionItem = () =>
2419
+ harness.events.flatMap((event) =>
2420
+ event.type === "turn_item.updated" && event.turnItem.type === "user_input_request"
2421
+ ? [event.turnItem]
2422
+ : [],
2423
+ )[0];
2424
+ const request = () =>
2425
+ harness.events.flatMap((event) =>
2426
+ event.type === "runtime_request.updated" ? [event.runtimeRequest] : [],
2427
+ )[0];
2428
+ yield* harness.until(() => questionItem() !== undefined && request() !== undefined);
2429
+ const publishedId = questionItem()!.questions[0]!.id;
2430
+ yield* harness.runtime.respondToRuntimeRequest({
2431
+ requestId: request()!.id,
2432
+ answers: { [publishedId]: ["A"] },
2433
+ });
2434
+ yield* harness.firstTerminal;
2435
+ }).pipe(
2436
+ Effect.provide(
2437
+ Layer.mergeAll(
2438
+ IdAllocator.layer,
2439
+ McpProviderSessions.layer,
2440
+ NodeServices.layer,
2441
+ NodeCrypto.layer,
2442
+ ),
2443
+ ),
2444
+ ),
2445
+ ),
2446
+ );
2447
+
2448
it.effect("records the model Codex reports on the root provider turn", () =>
2449
Effect.scoped(
2450
Effect.gen(function* () {
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+15
-11
@@ -668,14 +668,15 @@ function answerValueToStrings(value: unknown): ReadonlyArray<string> {
668
669
function toCodexUserInputAnswers(
670
answers: ProviderUserInputAnswers,
671
- allowedQuestionIds: ReadonlySet<string>,
671
+ nativeQuestionIds: ReadonlyMap<string, string>,
672
): CodexSchema.ToolRequestUserInputResponse["answers"] {
673
return Object.fromEntries(
674
- Object.entries(answers).flatMap(([questionId, value]) =>
675
- allowedQuestionIds.has(questionId)
676
- ? [[questionId, { answers: [...answerValueToStrings(value)] }]]
677
- : [],
678
- ),
674
+ Object.entries(answers).flatMap(([questionId, value]) => {
675
+ const nativeId = nativeQuestionIds.get(questionId);
676
+ return nativeId === undefined
677
+ ? []
678
+ : [[nativeId, { answers: [...answerValueToStrings(value)] }]];
679
+ }),
680
);
681
}
682
@@ -4556,6 +4557,12 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
4557
`Provider thread ${input.context.providerThread.id} is missing a provider session id.`,
4558
);
4559
}
4560
+ const nativeQuestionIds = new Map(
4561
+ input.questions.map((question, index) => [
4562
+ nonEmptyText(question.id, `question-${index + 1}`),
4563
+ question.id,
4564
+ ]),
4565
+ );
4566
const questions = input.questions.map((question, index) => ({
4567
id: nonEmptyText(question.id, `question-${index + 1}`),
4568
header: nonEmptyText(question.header, "Question"),
@@ -4630,7 +4637,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
4637
questions,
4638
...(input.responseMode === undefined ? {} : { responseMode: input.responseMode }),
4639
};
4633
- return { node, request, turnItem };
4640
+ return { node, request, turnItem, nativeQuestionIds };
4641
});
4642
4643
yield* client.handleServerNotification("item/agentMessage/delta", (payload) =>
@@ -6103,10 +6110,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
6110
),
6111
);
6112
return {
6106
- answers: toCodexUserInputAnswers(
6107
- resolved,
6108
- new Set(payload.questions.map((question) => question.id)),
6109
- ),
6113
+ answers: toCodexUserInputAnswers(resolved, artifacts.nativeQuestionIds),
6114
} satisfies CodexSchema.ToolRequestUserInputResponse;
6115
}).pipe(Effect.orDie),
6116
);