Skip to content

Commit 2d30009

Browse files
test(codex): question answers keep the native question id
Reproduces #35850: a requestUserInput question whose id has surrounding whitespace is published trimmed, and the answer keyed by the published id is dropped before the response reaches Codex. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 95cb068 commit 2d30009

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

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

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,95 @@ describe("CodexAdapterV2 post-settle continuation", () => {
23562356
),
23572357
);
23582358

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+
23592448
it.effect("records the model Codex reports on the root provider turn", () =>
23602449
Effect.scoped(
23612450
Effect.gen(function* () {

0 commit comments

Comments
 (0)