Skip to content

Commit 3e81a57

Browse files
committed
Accept max/ultra effort and persist review threads
Plumb reasoning effort through the review path and keep review threads around after they finish. - Accept "max" and "ultra" as reasoning-effort values in the companion validator and usage text. - Parse --effort (and --model) on review and adversarial-review, and pass the effort to the app-server as a per-thread config override (model_reasoning_effort). - Give review/adversarial threads a human title ("Codex Review vs <base>") and start them with ephemeral: false so they persist in the session index and rollout logs instead of being discarded. The effort plumbing mirrors upstream PR openai#471; the thread persistence (ephemeral: false + named review threads) is a local addition on top.
1 parent db52e28 commit 3e81a57

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

plugins/codex/scripts/codex-companion.mjs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const ROOT_DIR = path.resolve(fileURLToPath(new URL("..", import.meta.url)));
6868
const REVIEW_SCHEMA = path.join(ROOT_DIR, "schemas", "review-output.schema.json");
6969
const DEFAULT_STATUS_WAIT_TIMEOUT_MS = 240000;
7070
const DEFAULT_STATUS_POLL_INTERVAL_MS = 2000;
71-
const VALID_REASONING_EFFORTS = new Set(["none", "minimal", "low", "medium", "high", "xhigh"]);
71+
const VALID_REASONING_EFFORTS = new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]);
7272
const MODEL_ALIASES = new Map([["spark", "gpt-5.3-codex-spark"]]);
7373
const STOP_REVIEW_TASK_MARKER = "Run a stop-gate review of the previous Claude turn.";
7474

@@ -77,9 +77,9 @@ function printUsage() {
7777
[
7878
"Usage:",
7979
" node scripts/codex-companion.mjs setup [--enable-review-gate|--disable-review-gate] [--json]",
80-
" node scripts/codex-companion.mjs review [--wait|--background] [--base <ref>] [--scope <auto|working-tree|branch>]",
81-
" node scripts/codex-companion.mjs adversarial-review [--wait|--background] [--base <ref>] [--scope <auto|working-tree|branch>] [focus text]",
82-
" node scripts/codex-companion.mjs task [--background] [--write] [--resume-last|--resume|--fresh] [--model <model|spark>] [--effort <none|minimal|low|medium|high|xhigh>] [prompt]",
80+
" node scripts/codex-companion.mjs review [--wait|--background] [--base <ref>] [--scope <auto|working-tree|branch>] [--model <model|spark>] [--effort <none|minimal|low|medium|high|xhigh|max|ultra>]",
81+
" node scripts/codex-companion.mjs adversarial-review [--wait|--background] [--base <ref>] [--scope <auto|working-tree|branch>] [--model <model|spark>] [--effort <none|minimal|low|medium|high|xhigh|max|ultra>] [focus text]",
82+
" node scripts/codex-companion.mjs task [--background] [--write] [--resume-last|--resume|--fresh] [--model <model|spark>] [--effort <none|minimal|low|medium|high|xhigh|max|ultra>] [prompt]",
8383
" node scripts/codex-companion.mjs transfer [--source <claude-jsonl>] [--json]",
8484
" node scripts/codex-companion.mjs status [job-id] [--all] [--json]",
8585
" node scripts/codex-companion.mjs result [job-id] [--json]",
@@ -121,7 +121,7 @@ function normalizeReasoningEffort(effort) {
121121
}
122122
if (!VALID_REASONING_EFFORTS.has(normalized)) {
123123
throw new Error(
124-
`Unsupported reasoning effort "${effort}". Use one of: none, minimal, low, medium, high, xhigh.`
124+
`Unsupported reasoning effort "${effort}". Use one of: none, minimal, low, medium, high, xhigh, max, ultra.`
125125
);
126126
}
127127
return normalized;
@@ -355,6 +355,11 @@ async function resolveLatestTrackedTaskThread(cwd, options = {}) {
355355
return findLatestTaskThread(workspaceRoot);
356356
}
357357

358+
function buildReviewThreadName(request) {
359+
const scope = request.base ? ` vs ${request.base}` : "";
360+
return `Codex ${request.reviewName ?? "Review"}${scope}`;
361+
}
362+
358363
async function executeReviewRun(request) {
359364
ensureCodexAvailable(request.cwd);
360365
ensureGitRepository(request.cwd);
@@ -370,6 +375,8 @@ async function executeReviewRun(request) {
370375
const result = await runAppServerReview(request.cwd, {
371376
target: reviewTarget,
372377
model: request.model,
378+
effort: request.effort,
379+
threadName: buildReviewThreadName(request),
373380
onProgress: request.onProgress
374381
});
375382
const payload = {
@@ -411,6 +418,9 @@ async function executeReviewRun(request) {
411418
const result = await runAppServerTurn(context.repoRoot, {
412419
prompt,
413420
model: request.model,
421+
effort: request.effort,
422+
persistThread: true,
423+
threadName: buildReviewThreadName(request),
414424
sandbox: "read-only",
415425
outputSchema: readOutputSchema(REVIEW_SCHEMA),
416426
onProgress: request.onProgress
@@ -711,7 +721,7 @@ function enqueueBackgroundTask(cwd, job, request) {
711721

712722
async function handleReviewCommand(argv, config) {
713723
const { options, positionals } = parseCommandInput(argv, {
714-
valueOptions: ["base", "scope", "model", "cwd"],
724+
valueOptions: ["base", "scope", "model", "effort", "cwd"],
715725
booleanOptions: ["json", "background", "wait"],
716726
aliasMap: {
717727
m: "model"
@@ -744,6 +754,7 @@ async function handleReviewCommand(argv, config) {
744754
base: options.base,
745755
scope: options.scope,
746756
model: options.model,
757+
effort: normalizeReasoningEffort(options.effort),
747758
focusText,
748759
reviewName: config.reviewName,
749760
onProgress: progress

plugins/codex/scripts/lib/codex.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function buildThreadParams(cwd, options = {}) {
6666
model: options.model ?? null,
6767
approvalPolicy: options.approvalPolicy ?? "never",
6868
sandbox: options.sandbox ?? "read-only",
69+
config: options.effort ? { model_reasoning_effort: options.effort } : null,
6970
serviceName: SERVICE_NAME,
7071
ephemeral: options.ephemeral ?? true
7172
};
@@ -1009,8 +1010,9 @@ export async function runAppServerReview(cwd, options = {}) {
10091010
emitProgress(options.onProgress, "Starting Codex review thread.", "starting");
10101011
const thread = await startThread(client, cwd, {
10111012
model: options.model,
1013+
effort: options.effort,
10121014
sandbox: "read-only",
1013-
ephemeral: true,
1015+
ephemeral: false,
10141016
threadName: options.threadName
10151017
});
10161018
const sourceThreadId = thread.thread.id;
@@ -1113,6 +1115,7 @@ export async function runAppServerTurn(cwd, options = {}) {
11131115
emitProgress(options.onProgress, "Starting Codex task thread.", "starting");
11141116
const response = await startThread(client, cwd, {
11151117
model: options.model,
1118+
effort: options.effort,
11161119
sandbox: options.sandbox,
11171120
ephemeral: options.persistThread ? false : true,
11181121
threadName: options.persistThread ? options.threadName : options.threadName ?? null

0 commit comments

Comments
 (0)