Skip to content

fix(persona-kit): warn and skip approvalPolicy on codex 0.1.77+#167

Merged
khaliqgant merged 3 commits into
mainfrom
fix/codex-approval-policy-flag-v2
May 29, 2026
Merged

fix(persona-kit): warn and skip approvalPolicy on codex 0.1.77+#167
khaliqgant merged 3 commits into
mainfrom
fix/codex-approval-policy-flag-v2

Conversation

@kjgbot
Copy link
Copy Markdown
Contributor

@kjgbot kjgbot commented May 29, 2026

Supersedes #166 (clean rebase onto latest main).

Root cause

buildInteractiveSpec was generating codex exec ... --ask-for-approval <policy>. That flag was removed in codex 0.1.77+ (replaced by --sandbox + --dangerously-bypass-approvals-and-sandbox). Any persona with harnessSettings.approvalPolicy set (e.g. proactive-agent-builder.json with "approvalPolicy": "on-request") caused every codex agent step to exit immediately:

error: unexpected argument '--ask-for-approval' found

This surfaced in ricky's auto-fix/repair loop as a captured warning, burning the full 7-retry budget (~hours per spec in overnight runs).

Fix

  • interactive-spec.ts: emit a deprecation warning and skip the flag — on-request (most common value) is default behavior anyway; never is already covered by dangerouslyBypassApprovalsAndSandbox: true
  • types.ts: split @deprecated from @description so ts-json-schema-generator emits "deprecated": true (boolean, per JSON Schema 2020-12) + a separate description
  • persona.schema.json: regenerated — now has "deprecated": true, "description": "..." instead of the previous "deprecated": "<string>"
  • interactive-spec.test.ts: assert flag is NOT emitted and deprecation warning IS present

Verification

  • npm test in packages/persona-kit → 229/229 pass

🤖 Generated with Claude Code

kjgbot and others added 2 commits May 29, 2026 09:56
The `--ask-for-approval` flag was removed from codex in 0.1.77 (replaced
by `--sandbox <mode>` + `--dangerously-bypass-approvals-and-sandbox`).
`buildInteractiveSpec` was still generating `--ask-for-approval <policy>`
for any persona that set `harnessSettings.approvalPolicy`, causing every
codex agent step to fail immediately with a parse error:

  error: unexpected argument '--ask-for-approval' found

This surfaced in ricky's auto-fix loop as a warning that prevented
workflow repair and caused every auto-fix iteration to burn its full
retry budget (~hours per spec in overnight runs).

Fix: emit a deprecation warning and skip the flag entirely. The bypass
case is already handled by `dangerouslyBypassApprovalsAndSandbox: true`.
Mark `approvalPolicy` as @deprecated in the type definition.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…pprovalPolicy

ts-json-schema-generator with jsDoc:'extended' emits the @deprecated tag
text as the value when text is present, producing a non-standard string.
Separate the tag from the description so the generator emits
`"deprecated": true` + `"description": "..."` per JSON Schema 2020-12.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 76888510-adfe-4ab3-a02d-26c110e75450

📥 Commits

Reviewing files that changed from the base of the PR and between 90cd3de and 88b6788.

📒 Files selected for processing (2)
  • packages/persona-kit/src/interactive-spec.test.ts
  • packages/persona-kit/src/interactive-spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/persona-kit/src/interactive-spec.ts

📝 Walkthrough

Walkthrough

The PR deprecates HarnessSettings.approvalPolicy across schema, types, implementation, and tests. The unsupported --ask-for-approval CLI flag (removed in codex 0.1.77+) is no longer emitted; a warning directs users to dangerouslyBypassApprovalsAndSandbox or sandboxMode.

Changes

Deprecate approvalPolicy flag

Layer / File(s) Summary
Type and schema contract deprecation
packages/persona-kit/schemas/persona.schema.json, packages/persona-kit/src/types.ts
approvalPolicy is marked deprecated in the JSON schema and type documentation, with guidance explaining that --ask-for-approval was removed in codex 0.1.77+ and recommending alternatives.
Implementation warning and flag removal
packages/persona-kit/src/interactive-spec.ts
The codex harness branch now emits a deprecation warning when approvalPolicy is set and skips pushing the unsupported --ask-for-approval flag entirely.
Test updates for deprecation behavior
packages/persona-kit/src/interactive-spec.test.ts
Test expectations are updated to remove --ask-for-approval from the asserted args and to verify that a warning is emitted; a new test ensures the warning still appears when dangerouslyBypassApprovalsAndSandbox is set.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AgentWorkforce/workforce#53: Adds approvalPolicy wiring into Codex launch args; overlaps with this PR's removal/deprecation of the same flag.
  • AgentWorkforce/workforce#86: Modifies Codex buildInteractiveSpec and bypass flags; closely related to changes around dangerouslyBypassApprovalsAndSandbox and --ask-for-approval.
  • AgentWorkforce/workforce#125: Ensures dangerouslyBypassApprovalsAndSandbox handling when loading personas; relevant to combined warning/bypass behavior tested here.

Suggested reviewers

  • willwashburn

Poem

🐰 I sniffed the code and gave a hop,
The old approval flag met the chop.
A gentle warning now I sing,
Use sandbox paths — that's the thing! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: deprecating and skipping the removed --ask-for-approval flag in codex 0.1.77+, with a clear action verb and scope.
Description check ✅ Passed The description comprehensively explains the root cause, the fix applied across multiple files, and provides verification that all tests pass.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/codex-approval-policy-flag-v2

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request deprecates the approvalPolicy configuration across schemas, types, and the spec builder, as the --ask-for-approval flag has been removed in codex 0.1.77+. Instead of passing the flag, the code now emits a deprecation warning. The reviewer pointed out that this warning is currently skipped when dangerouslyBypassApprovalsAndSandbox is enabled because the check is nested inside an else block, and suggested refactoring the check to be outside of the conditional block so that the warning is always emitted.

Comment on lines 265 to 275
if (harnessSettings?.approvalPolicy) {
args.push('--ask-for-approval', harnessSettings.approvalPolicy);
// `--ask-for-approval` was removed in codex 0.1.77+ (replaced by
// `--sandbox` + `--dangerously-bypass-approvals-and-sandbox`).
// Emit a warning and skip the flag rather than pass an unknown arg
// that causes codex to exit immediately with a parse error.
warnings.push(
`codex harnessSettings.approvalPolicy ("${harnessSettings.approvalPolicy}") is not supported in codex 0.1.77+; ` +
`the --ask-for-approval flag was removed. Use dangerouslyBypassApprovalsAndSandbox: true for non-interactive execution, ` +
`or sandboxMode for filesystem access control.`
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When dangerouslyBypassApprovalsAndSandbox is set to true, the else block is skipped entirely. As a result, the deprecation warning for approvalPolicy will not be emitted even if it is defined in harnessSettings. Since approvalPolicy is deprecated and ignored in all cases, the deprecation warning should be checked and emitted regardless of whether dangerouslyBypassApprovalsAndSandbox is enabled. Consider refactoring the approvalPolicy check to be outside of the if-else block.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/persona-kit/src/interactive-spec.ts (1)

256-275: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Emit approvalPolicy deprecation warning regardless of bypass mode.

When both dangerouslyBypassApprovalsAndSandbox and approvalPolicy are set, approvalPolicy is still ignored but no warning is emitted due to branch placement. The warning should fire whenever approvalPolicy is present.

Proposed fix
       const args = ['-m', stripProviderPrefix(model)];
       if (mcpServers && Object.keys(mcpServers).length > 0) {
         appendCodexMcpServerArgs(args, mcpServers, warnings);
       }
+      if (harnessSettings?.approvalPolicy) {
+        warnings.push(
+          `codex harnessSettings.approvalPolicy ("${harnessSettings.approvalPolicy}") is not supported in codex 0.1.77+; ` +
+            `the --ask-for-approval flag was removed. Use dangerouslyBypassApprovalsAndSandbox: true for non-interactive execution, ` +
+            `or sandboxMode for filesystem access control.`
+        );
+      }
       if (harnessSettings?.dangerouslyBypassApprovalsAndSandbox) {
         // Single combined flag — collapses "no sandbox + never ask" and
         // suppresses codex's interactive "are you sure?" startup
         // confirmation. The two-flag form below still prompts.
         args.push('--dangerously-bypass-approvals-and-sandbox');
       } else {
         if (harnessSettings?.sandboxMode) {
           args.push('--sandbox', harnessSettings.sandboxMode);
         }
-        if (harnessSettings?.approvalPolicy) {
-          // `--ask-for-approval` was removed in codex 0.1.77+ (replaced by
-          // `--sandbox` + `--dangerously-bypass-approvals-and-sandbox`).
-          // Emit a warning and skip the flag rather than pass an unknown arg
-          // that causes codex to exit immediately with a parse error.
-          warnings.push(
-            `codex harnessSettings.approvalPolicy ("${harnessSettings.approvalPolicy}") is not supported in codex 0.1.77+; ` +
-              `the --ask-for-approval flag was removed. Use dangerouslyBypassApprovalsAndSandbox: true for non-interactive execution, ` +
-              `or sandboxMode for filesystem access control.`
-          );
-        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/persona-kit/src/interactive-spec.ts` around lines 256 - 275, The
deprecation warning for harnessSettings.approvalPolicy should be emitted
regardless of dangerouslyBypassApprovalsAndSandbox; currently it's inside the
else branch and skipped when dangerouslyBypassApprovalsAndSandbox is true. Move
or duplicate the approvalPolicy check so that, after inspecting
harnessSettings.dangerouslyBypassApprovalsAndSandbox, you still run a
conditional that checks harnessSettings.approvalPolicy and pushes the same
message into warnings (referring to the existing warnings array and the same
message string), while leaving the existing args logic for
args.push('--dangerously-bypass-approvals-and-sandbox') and sandbox handling
(harnessSettings.sandboxMode) unchanged.
🧹 Nitpick comments (1)
packages/persona-kit/src/interactive-spec.test.ts (1)

117-130: ⚡ Quick win

Add regression coverage for approvalPolicy + bypass together.

Current assertions only cover approvalPolicy without dangerouslyBypassApprovalsAndSandbox. A focused case for both fields prevents warning-regression in this deprecation path.

Suggested test addition
+test('codex still warns about deprecated approvalPolicy when bypass flag is set', () => {
+  const result = buildInteractiveSpec({
+    harness: 'codex',
+    personaId: 'test-persona',
+    model: 'openai-codex/gpt-5.3-codex',
+    systemPrompt: 'x',
+    harnessSettings: {
+      reasoning: 'high',
+      timeoutSeconds: 1200,
+      approvalPolicy: 'never',
+      dangerouslyBypassApprovalsAndSandbox: true
+    }
+  });
+  assert.ok(result.args.includes('--dangerously-bypass-approvals-and-sandbox'));
+  assert.ok(result.warnings.some((w) => w.includes('approvalPolicy') && w.includes('not supported')));
+});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/persona-kit/src/interactive-spec.test.ts` around lines 117 - 130,
Add a focused test that exercises both approvalPolicy and
dangerouslyBypassApprovalsAndSandbox together: construct the same invocation
that produced result in interactive-spec.test.ts but include
dangerouslyBypassApprovalsAndSandbox: true alongside approvalPolicy, then assert
the resulting result.args still matches the expected flags (the same array
currently asserted) and assert result.warnings contains the deprecation message
for approvalPolicy but does NOT include any additional warning about bypass;
reference the existing result variable and the assertion blocks around
result.args and result.warnings to add this new check.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/persona-kit/src/interactive-spec.ts`:
- Around line 256-275: The deprecation warning for
harnessSettings.approvalPolicy should be emitted regardless of
dangerouslyBypassApprovalsAndSandbox; currently it's inside the else branch and
skipped when dangerouslyBypassApprovalsAndSandbox is true. Move or duplicate the
approvalPolicy check so that, after inspecting
harnessSettings.dangerouslyBypassApprovalsAndSandbox, you still run a
conditional that checks harnessSettings.approvalPolicy and pushes the same
message into warnings (referring to the existing warnings array and the same
message string), while leaving the existing args logic for
args.push('--dangerously-bypass-approvals-and-sandbox') and sandbox handling
(harnessSettings.sandboxMode) unchanged.

---

Nitpick comments:
In `@packages/persona-kit/src/interactive-spec.test.ts`:
- Around line 117-130: Add a focused test that exercises both approvalPolicy and
dangerouslyBypassApprovalsAndSandbox together: construct the same invocation
that produced result in interactive-spec.test.ts but include
dangerouslyBypassApprovalsAndSandbox: true alongside approvalPolicy, then assert
the resulting result.args still matches the expected flags (the same array
currently asserted) and assert result.warnings contains the deprecation message
for approvalPolicy but does NOT include any additional warning about bypass;
reference the existing result variable and the assertion blocks around
result.args and result.warnings to add this new check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c6916843-408d-402f-8d24-396c700503ae

📥 Commits

Reviewing files that changed from the base of the PR and between 4d9066a and 90cd3de.

📒 Files selected for processing (4)
  • packages/persona-kit/schemas/persona.schema.json
  • packages/persona-kit/src/interactive-spec.test.ts
  • packages/persona-kit/src/interactive-spec.ts
  • packages/persona-kit/src/types.ts

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/persona-kit/src/interactive-spec.ts Outdated
The deprecation warning was inside the `else` block, so it was silently
skipped when `dangerouslyBypassApprovalsAndSandbox: true` was also set.
Move the warning before the if/else so it always fires when approvalPolicy
is present, regardless of the bypass flag.

Add a test asserting the warning fires even with both fields set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@khaliqgant khaliqgant merged commit a5fb471 into main May 29, 2026
3 checks passed
@khaliqgant khaliqgant deleted the fix/codex-approval-policy-flag-v2 branch May 29, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants