Skip to content

fix(codex): defer report-mode plugin approvals - #87805

Merged
steipete merged 2 commits into
mainfrom
fix/codex-report-mode-plugin-approvals
May 28, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/codex-report-mode-plugin-approvals

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Wires Codex app-server report-mode PreToolUse plugin approval requirements into the real app-server approval request instead of failing closed in the native hook process.
  • Stores deferred native hook approvals by relay/tool-use id, shares in-flight decisions across duplicate app-server requests, and preserves rewrite/block fail-closed behavior.
  • Updates Codex hook docs and the Plugin SDK API baseline for the new agent-harness runtime helpers.

Supersedes #86978. Thanks @clawSean for the original docs clarification that exposed this missing runtime path.

Verification

  • node scripts/run-vitest.mjs src/agents/agent-tools.before-tool-call.embedded-mode.test.ts
  • node scripts/run-vitest.mjs src/agents/harness/native-hook-relay.test.ts
  • node scripts/run-vitest.mjs extensions/codex/src/app-server/approval-bridge.test.ts
  • pnpm plugin-sdk:api:check
  • pnpm tsgo:core
  • pnpm tsgo:extensions
  • git diff --check
  • pnpm docs:list
  • /Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/main --prompt-file /tmp/codex-report-mode-review-notes.md

Real behavior proof

Behavior addressed: Codex app-server report-mode PreToolUse hooks that return requireApproval now defer to the matching Codex app-server approval request and open a real OpenClaw plugin approval prompt.
Real environment tested: Local OpenClaw checkout on Node/Vitest with Codex app-server bridge and native hook relay unit coverage.
Exact steps or command run after this patch: node scripts/run-vitest.mjs src/agents/harness/native-hook-relay.test.ts; node scripts/run-vitest.mjs extensions/codex/src/app-server/approval-bridge.test.ts; pnpm tsgo:core; pnpm tsgo:extensions.
Evidence after fix: Focused tests cover deferred report-mode approval storage, duplicate app-server request sharing, app-server approval consumption, and plugin allow-always staying scoped to one Codex request.
Observed result after fix: All focused tests and type/API checks passed locally.
What was not tested: A live Codex app-server run with a human clicking the approval UI was not exercised locally.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: codex size: L maintainer Maintainer-authored PR labels May 28, 2026
@clawsweeper

clawsweeper Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(codex): defer report-mode plugin approvals This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: faf8ee1785

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +649 to +652
).finally(() => {
if (pendingPreToolUseApprovals.get(pendingApprovalKey) === pendingApproval) {
pendingPreToolUseApprovals.delete(pendingApprovalKey);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Preserve deferred denial outcomes for retries

When a deferred PreToolUse plugin approval resolves, this finally removes the only stored outcome. A later Codex app-server approval request for the same toolUseId still matches the recorded native invocation, but resolveNativeHookRelayDeferredToolApproval() then returns undefined; approval-bridge.ts treats that as handled: true/no-decision and falls through to the generic Codex approval route. In retry or duplicate-request scenarios after a plugin denial, that lets the user approve the command through Codex despite the plugin policy having denied it. Cache the resolved approval/denial for the relay/tool-use lifetime, or make a missing deferred outcome fail closed for an observed native invocation.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants