Skip to content

Commit c9a7790

Browse files
fix(server): Codex question answers keep their native question id
Question ids are trimmed (or given a fallback) before clients see them, but the reply to Codex filtered answers by the untrimmed native ids, so an id like " choice " lost its answer. Map each published id back to its native id when replying. Fixes #35850 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2d30009 commit c9a7790

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -668,14 +668,15 @@ function answerValueToStrings(value: unknown): ReadonlyArray<string> {
668668

669669
function toCodexUserInputAnswers(
670670
answers: ProviderUserInputAnswers,
671-
allowedQuestionIds: ReadonlySet<string>,
671+
nativeQuestionIds: ReadonlyMap<string, string>,
672672
): CodexSchema.ToolRequestUserInputResponse["answers"] {
673673
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+
}),
679680
);
680681
}
681682

@@ -4556,6 +4557,12 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
45564557
`Provider thread ${input.context.providerThread.id} is missing a provider session id.`,
45574558
);
45584559
}
4560+
const nativeQuestionIds = new Map(
4561+
input.questions.map((question, index) => [
4562+
nonEmptyText(question.id, `question-${index + 1}`),
4563+
question.id,
4564+
]),
4565+
);
45594566
const questions = input.questions.map((question, index) => ({
45604567
id: nonEmptyText(question.id, `question-${index + 1}`),
45614568
header: nonEmptyText(question.header, "Question"),
@@ -4630,7 +4637,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
46304637
questions,
46314638
...(input.responseMode === undefined ? {} : { responseMode: input.responseMode }),
46324639
};
4633-
return { node, request, turnItem };
4640+
return { node, request, turnItem, nativeQuestionIds };
46344641
});
46354642

46364643
yield* client.handleServerNotification("item/agentMessage/delta", (payload) =>
@@ -6103,10 +6110,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
61036110
),
61046111
);
61056112
return {
6106-
answers: toCodexUserInputAnswers(
6107-
resolved,
6108-
new Set(payload.questions.map((question) => question.id)),
6109-
),
6113+
answers: toCodexUserInputAnswers(resolved, artifacts.nativeQuestionIds),
61106114
} satisfies CodexSchema.ToolRequestUserInputResponse;
61116115
}).pipe(Effect.orDie),
61126116
);

0 commit comments

Comments
 (0)