feat(ai): standardized codex reasoning context to all_turns

- Standardized reasoning context to default to all_turns across all Codex requests to mirror codex-rs behavior.
- Updated request transformer logic to explicitly set reasoning context rather than omitting it when unset.
- Updated API documentation to reflect consistent all_turns default behavior and corrected internal references.
- Adjusted unit tests to verify the enforced all_turns default reasoning context expectation.
This commit is contained in:
can1357
2026-06-27 13:40:03 +02:00
parent 5b3a343a7e
commit 2708c1edb8
4 changed files with 14 additions and 14 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Changed
- Default reasoning context to `all_turns` for all Codex requests
## [16.2.2] - 2026-06-27
### Added
@@ -104,7 +104,7 @@ import { transformMessages } from "./transform-messages";
export interface OpenAICodexResponsesOptions extends StreamOptions {
reasoning?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
reasoningSummary?: "auto" | "concise" | "detailed" | null;
/** `reasoning.context` replay scope. Defaults to `all_turns` under {@link OpenAICodexResponsesOptions.responsesLite}, otherwise omitted (server default is `current_turn`). */
/** `reasoning.context` replay scope; defaults to `all_turns` for every Codex request when unset. */
reasoningContext?: CodexReasoningContext;
textVerbosity?: "low" | "medium" | "high";
include?: string[];
@@ -117,7 +117,7 @@ export interface OpenAICodexResponsesOptions extends StreamOptions {
* `x-openai-internal-codex-responses-lite: true` on HTTP requests and on the
* WebSocket upgrade (the marker is connection-scoped there, so lite and
* non-lite turns never share a pooled socket), strips image detail from
* input, and defaults `reasoning.context` to `all_turns` — mirroring codex-rs.
* input, and disables parallel tool calling — mirroring codex-rs.
*/
responsesLite?: boolean;
/**
@@ -14,11 +14,11 @@ export interface ReasoningConfig {
export interface CodexRequestOptions {
reasoningEffort?: ReasoningConfig["effort"];
reasoningSummary?: ReasoningConfig["summary"] | null;
/** Explicit `reasoning.context` override. Defaults to `all_turns` under {@link CodexRequestOptions.responsesLite}, otherwise omitted (server default is `current_turn`). */
/** Explicit `reasoning.context` override; defaults to `all_turns` for every Codex request when unset. */
reasoningContext?: CodexReasoningContext;
textVerbosity?: "low" | "medium" | "high";
include?: string[];
/** Responses Lite transport contract: strips image detail and defaults `reasoning.context` to `all_turns`, mirroring codex-rs. */
/** Responses Lite transport contract: strips image detail and disables parallel tool calling, mirroring codex-rs. */
responsesLite?: boolean;
}
@@ -254,13 +254,9 @@ export async function transformRequestBody(
...body.reasoning,
...reasoningConfig,
};
// Responses Lite keeps reasoning replay server-side; codex-rs requests
// `all_turns` there and otherwise omits context so the server default
// (currently `current_turn`) applies.
const reasoningContext = options.reasoningContext ?? "all_turns";
if (reasoningContext !== undefined) {
body.reasoning.context = reasoningContext;
}
// Default reasoning replay to `all_turns` for every Codex request,
// mirroring codex-rs; an explicit `reasoningContext` overrides it.
body.reasoning.context = options.reasoningContext ?? "all_turns";
} else {
delete body.reasoning;
}
@@ -83,7 +83,7 @@ function createCodexFetchMock(sse: string, onRequest: (captured: CapturedCodexRe
}
describe("openai-codex reasoning.context", () => {
it("forwards an explicit reasoning.context and omits it by default", async () => {
it("forwards an explicit reasoning.context and defaults to all_turns", async () => {
const model = createCodexModel("gpt-5.1-codex");
const explicit = await transformRequestBody({ model: model.id }, model, {
@@ -92,8 +92,8 @@ describe("openai-codex reasoning.context", () => {
});
expect(explicit.reasoning?.context).toBe("current_turn");
const omitted = await transformRequestBody({ model: model.id }, model, { reasoningEffort: "medium" });
expect(omitted.reasoning?.context).toBeUndefined();
const defaulted = await transformRequestBody({ model: model.id }, model, { reasoningEffort: "medium" });
expect(defaulted.reasoning?.context).toBe("all_turns");
});
it("defaults reasoning.context to all_turns under Responses Lite unless overridden", async () => {