Skip to content

fix(approvals): handle stale plugin waits - #88203

Merged
steipete merged 2 commits into
openclaw:mainfrom
TurboTheTurtle:fix/stale-plugin-approval-wait-88111
Jul 21, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
TurboTheTurtle:fix/stale-plugin-approval-wait-88111

Conversation

@TurboTheTurtle

@TurboTheTurtle TurboTheTurtle commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #88111

What Problem This Solves

Fixes stale plugin.approval.waitDecision identifiers escaping as generic runtime failures from exec, Codex app-server, and native PermissionRequest waits. Approval state can legitimately disappear after expiry, restart, or caller lifecycle drift; those cases must stay fail closed without crashing the whole turn.

Why This Change Was Made

The shared approval-not-found classifier now recognizes both gateway message variants. Exec uses the canonical classifier; Codex app-server maps stale waits to unavailable/decline; native PermissionRequest maps them to no hook verdict so Codex continues through its normal guardian/user approval path. Error classification is attached only to gateway wait promises, so abort races and unrelated errors preserve their existing propagation.

Current main's newer phase-aware before-tool classification is retained and the obsolete Plugin SDK budget churn is omitted.

User Impact

Expired approval waits deny or defer cleanly instead of terminating agent turns with misleading generic errors. No stale approval can authorize a tool.

Evidence

  • Focused suites: approval classifier 7, exec/native 15, Codex bridge 82 — 104 passed.
  • Current before-tool sibling suite — 84 passed.
  • Structured autoreview found two abort-race issues; both were fixed. Final autoreview clean, confidence 0.95.
  • Contributor real-behavior proof used an authenticated isolated loopback gateway and confirmed the live error approval expired or not found is recognized by the shared classifier.

Direct Codex contract check at sibling 9970cd706fc4f25bbb97b42f4b68d993dabe91e2:

  • codex-rs/hooks/src/events/permission_request.rs:1-15,50-60,98-117 defines no hook verdict as deferral to normal approval.
  • codex-rs/app-server-protocol/src/protocol/v2/item.rs:57-114 defines decline as denial while continuing the turn.
  • codex-rs/app-server/src/bespoke_event_handling.rs:1885-1922 fails closed on missing/failed approval responses.

Credit

Maintainer rewrite of Andy Ye's contribution (@TurboTheTurtle), preserved with Co-authored-by: Andy Ye <[email protected]>.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: codex size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 30, 2026
@clawsweeper

clawsweeper Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 15, 2026, 10:01 PM ET / July 16, 2026, 02:01 UTC.

Summary
The PR classifies missing or expired approval waits and maps them to fail-closed outcomes across plugin before-tool, Codex app-server, native-hook relay, and exec approval consumers.

PR surface: Source +26, Tests +107, Other 0. Total +133 across 10 files.

Reproducibility: yes. at source level: current main still emits the stale waitDecision error, while the Codex and native-hook consumers still allow that rejection to escape; the contributor also supplied a real gateway reproduction on the proof head.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #88111
Summary: This PR is the direct implementation candidate for the canonical stale plugin-wait issue; adjacent approval work changes identifier diagnostics or abort cleanup but does not replace the remaining Codex/native stale-wait fix.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The PR head is not cleanly mergeable with current main, whose approval classifier and before-tool catch behavior have materially evolved since this branch was prepared.
  • [P1] The change intentionally converts exceptional stale-wait failures into decline, unavailable, or deferred outcomes; maintainers should confirm those cross-surface approval semantics before landing.
  • [P1] A careless conflict resolution could discard current main's phase-aware request-versus-wait diagnostics or its newer structured stale-approval classification.

Maintainer options:

  1. Rebase around current approval semantics (recommended)
    Resolve the conflicts by retaining current main's request-versus-wait diagnostics and structured classifier, then apply stale normalization only to the remaining unhandled consumers.
  2. Pause for approval-policy direction
    Leave the PR open but do not merge until maintainers decide whether Codex and native-hook stale waits should recover or remain exceptional.

Next step before merge

  • [P2] A maintainer should confirm the cross-surface stale-approval outcomes and request a clean rebase that preserves current main; the branch conflict and approval-boundary choice are not a safe autonomous repair.

Maintainer decision needed

  • Question: Should stale plugin waitDecision identifiers be normalized to decline/unavailable outcomes in the Codex bridge and to no hook verdict in native PermissionRequest, while preserving current main's fail-closed before-tool behavior?
  • Rationale: These outcomes determine whether an expired approval becomes a recoverable denial, falls through to Codex's normal approval flow, or aborts the agent turn; the code can implement any choice, but approval-boundary intent belongs to maintainers.
  • Likely owner: steipete — Recent merged work defines the current phase-aware approval behavior and the file history shows extensive ownership of the native-hook lifecycle.
  • Options:
    • Normalize and rebase (recommended): Confirm the proposed fail-closed semantics, rebase the branch onto current main, and preserve the newer phase-aware classifier and diagnostics.
    • Keep exceptional failures: Retain thrown stale-wait failures for one or more surfaces and close or narrow this PR after documenting why turn interruption is preferred there.

Security
Cleared: The patch preserves denial or normal approval fallback rather than authorizing stale requests, and the upstream Codex PermissionRequest contract confirms empty successful output produces no hook verdict.

Review details

Best possible solution:

Rebase onto current main, retain its phase-aware before-tool diagnostics and structured stale classifier, add the legacy waitDecision message to that canonical classifier, and use it only in the remaining Codex, native-hook, and exec consumers with focused regression coverage.

Do we have a high-confidence way to reproduce the issue?

Yes at source level: current main still emits the stale waitDecision error, while the Codex and native-hook consumers still allow that rejection to escape; the contributor also supplied a real gateway reproduction on the proof head.

Is this the best way to solve the issue?

Yes in principle, but not as a direct merge of the stale branch; the best fix is the same shared classification approach rebased onto current main without replacing its newer phase-aware handling.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 154d53c4f6fc.

Label changes

Label justifications:

  • P2: This is a normal-priority reliability and approval-safety fix with limited blast radius across several agent approval consumers.
  • merge-risk: 🚨 compatibility: Merging changes stale approval failures from thrown runtime errors to decline, unavailable, or deferred outcomes and must preserve newer current-main behavior during conflict resolution.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes redacted after-fix live output from a real authenticated loopback gateway/client stale-ID request plus focused production-path tests showing the mapped outcomes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted after-fix live output from a real authenticated loopback gateway/client stale-ID request plus focused production-path tests showing the mapped outcomes.
Evidence reviewed

PR surface:

Source +26, Tests +107, Other 0. Total +133 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 65 39 +26
Tests 4 107 0 +107
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 4 0
Total 10 176 43 +133

What I checked:

  • Canonical bug remains partly present: Current main still lets stale plugin waitDecision errors escape from the Codex app-server helper rather than returning an unavailable outcome. (extensions/codex/src/app-server/plugin-approval-roundtrip.ts:92, 154d53c4f6fc)
  • Native-hook path remains unhandled: Current main still awaits plugin.approval.waitDecision directly in the native PermissionRequest relay, so a stale identifier rejects the hook invocation instead of yielding no hook verdict. (src/agents/harness/native-hook-relay.ts:2055, 154d53c4f6fc)
  • Gateway stale response contract: The shared gateway wait handler still returns INVALID_REQUEST with the message approval expired or not found when the approval snapshot or decision promise is absent. (src/gateway/server-methods/approval-shared.ts:366, 154d53c4f6fc)
  • Current-main overlap: Merged work now distinguishes request-phase validation failures from wait-phase INVALID_REQUEST failures in before_tool_call, so this branch must preserve that newer phase-aware behavior rather than replaying its older catch logic unchanged. (src/agents/agent-tools.before-tool-call.ts:930, 154d53c4f6fc)
  • Current classifier evolved: Current main contains structured approval-not-found and already-resolved classification that is newer than the PR branch; conflict resolution must retain it while adding the remaining legacy wait message. (src/infra/approval-errors.ts:1, 154d53c4f6fc)
  • Codex hook contract checked: Codex PermissionRequest hooks explicitly allow handlers to decline to decide; empty successful output produces no hook verdict and lets the normal guardian or user approval flow continue. (../codex/codex-rs/hooks/src/events/permission_request.rs:1)

Likely related people:

  • joshavant: Authored the merged async requireApproval work that established the plugin approval gateway methods, protocol, and before-tool behavior affected by this PR. (role: introduced plugin approval behavior; confidence: high; commits: 6ade9c474cf1; files: src/agents/agent-tools.before-tool-call.ts, src/gateway/server-methods/plugin-approval.ts, packages/gateway-protocol/src/schema/plugin-approvals.ts)
  • steipete: Recent history and merged phase-aware approval-error work cover the same before-tool and native-hook decision surfaces that now conflict with this branch. (role: recent approval and native-relay contributor; confidence: high; commits: 862de9f1a1c2, 450642a, 56a5d7e; files: src/agents/agent-tools.before-tool-call.ts, src/agents/harness/native-hook-relay.ts, extensions/codex/src/app-server/plugin-approval-roundtrip.ts)
  • vincentkoc: Authored recent error-normalization and agent-runtime work on the native relay path and is a useful secondary owner for integrating the shared classifier cleanly. (role: recent adjacent runtime contributor; confidence: medium; commits: 80805ad, e085fa1a3ffd; files: src/agents/harness/native-hook-relay.ts, src/agents/agent-tools.before-tool-call.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-06-29T01:04:06.540Z sha 62d3f970e5b66cf6169e3658a16531d87ffcb9e5 :: needs maintainer review before merge. :: none
  • reviewed July 13, 2026, 10:49 PM ET / July 14, 2026, 02:49 UTC sha unknown :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 30, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels May 30, 2026
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

Added real gateway/client stale-id proof to the PR body. It starts a real loopback gateway, calls plugin.approval.waitDecision with a stale plugin approval id, observes the live gateway/client error approval expired or not found, and shows the patched isApprovalNotFoundError classifier returns true.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 30, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/stale-plugin-approval-wait-88111 branch from b45c8d7 to 017babe Compare May 31, 2026 19:41
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 31, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/stale-plugin-approval-wait-88111 branch 3 times, most recently from 925b735 to 3c80ada Compare May 31, 2026 19:59
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels May 31, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/stale-plugin-approval-wait-88111 branch from 3c80ada to 9a74efa Compare May 31, 2026 20:09
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 31, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels May 31, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 5, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/stale-plugin-approval-wait-88111 branch from f78c8ae to 6d0a0a0 Compare June 28, 2026 22:48
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jun 28, 2026
@TurboTheTurtle
TurboTheTurtle force-pushed the fix/stale-plugin-approval-wait-88111 branch from 6d0a0a0 to d0270e4 Compare June 28, 2026 23:56
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jun 29, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 14, 2026
Recognize the gateway stale-id message through the shared classifier and map stale exec, Codex app-server, and native PermissionRequest waits to their existing fail-closed or defer contracts without swallowing aborts.

Closes openclaw#88111

Co-authored-by: Andy Ye <[email protected]>
@steipete steipete self-assigned this Jul 21, 2026
@steipete
steipete force-pushed the fix/stale-plugin-approval-wait-88111 branch from 62d3f97 to aa07560 Compare July 21, 2026 08:38
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed scripts Repository scripts size: M labels Jul 21, 2026
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(approvals): handle stale plugin waits 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.

Satisfy the catch-callback unknown lint without changing approval behavior.

Co-authored-by: Andy Ye <[email protected]>
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(approvals): handle stale plugin waits 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.

@steipete

Copy link
Copy Markdown
Contributor

Maintainer pre-merge verification for 0e5eebea1caf58b60b57197b2b4100a89a1bd163:

  • Rewrote the stale branch around current main: retained phase-aware before-tool handling, extended the canonical classifier, and updated only exec, Codex app-server, and native PermissionRequest wait consumers.
  • Preserved fail-closed semantics: exec uses askFallback, app-server stale waits decline/unavailable, and native stale waits produce no hook verdict so Codex continues through normal guardian/user approval.
  • Scoped stale classification to gateway wait promises; abort races and unrelated errors retain their existing propagation.
  • Preserved Andy Ye as co-author.
  • Focused approval suites: 104 passed; current before-tool sibling suite: 84 passed.
  • Initial autoreview found two abort-race bugs; both were fixed. Final autoreview clean at 0.95; lint-only follow-up review clean at 0.99.
  • Exact-head hosted CI passed: https://github.com/openclaw/openclaw/actions/runs/29815667521

Direct Codex contract check at sibling 9970cd706fc4f25bbb97b42f4b68d993dabe91e2:

  • codex-rs/hooks/src/events/permission_request.rs:1-15,50-60,98-117 defines no hook verdict as deferral to normal approval.
  • codex-rs/app-server-protocol/src/protocol/v2/item.rs:57-114 defines decline as denial while continuing the turn.
  • codex-rs/app-server/src/bespoke_event_handling.rs:1885-1922 fails closed on approval response failures.

Reviewed source head: 0e5eebe
Original contributor head: 62d3f97

@steipete
steipete merged commit 5f05c54 into openclaw:main Jul 21, 2026
117 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 22, 2026
* fix(approvals): handle stale plugin waits

Recognize the gateway stale-id message through the shared classifier and map stale exec, Codex app-server, and native PermissionRequest waits to their existing fail-closed or defer contracts without swallowing aborts.

Closes openclaw#88111

Co-authored-by: Andy Ye <[email protected]>

* style(approvals): type stale wait catch values

Satisfy the catch-callback unknown lint without changing approval behavior.

Co-authored-by: Andy Ye <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale plugin approval waits should fail closed instead of failing agent turns

2 participants