Repository navigation
fix: keep delegated approvals alive until their outcome - #137017
Conversation
Wait for the actual delegated OpenClaw approval/application result without holding system-agent serialization or extending closed-run authority. Keep human approval on a direct model tool call so yielded Code Mode cells cannot strand it. Preserve cancellation and truthful denial/expiry results. Verified real authenticated Allow after 95 seconds, Deny, Stop, and natural 600-second expiry; late approvals preserve terminal state and perform no write. Related: #134557. No configuration, SQLite, or protocol changes.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Exact-head integration proofRefreshed all four authenticated real-browser flows on PR head
Late Allow after Deny, Stop, and expiry returned The exact-head conversation-only recordings appended last show Allow and natural expiry, in that order. They were cropped to exclude operator identity chrome, then inspected across the full duration and final frames; the approval controls, countdown, final response and permission posture remain visible. CI run 33717961345, attempt 1 completed successfully for the exact head; required Exact local test command: node scripts/run-vitest.mjs src/agents/tools/openclaw-delegate-tool.test.ts src/gateway/server-methods/system-agent-approval.test.ts src/gateway/server-methods/system-agent-approval-authority.test.ts src/gateway/server-methods/system-agent.test.ts extensions/codex/src/app-server/dynamic-tool-build.test.ts extensions/codex/src/app-server/dynamic-tool-execution.test.tsLatest ClawSweeper status is a running-review placeholder, with no published findings or Rank-up moves to apply or skip at this check. Independent review and exact-head validation are complete; any findings published before merge will be checked. |
|
Codex review: blocked before merge. Reviewed September 3, 2026, 2:04 AM ET / 06:04 UTC. ClawSweeper reviewWhat this changesThe PR keeps delegated OpenClaw approval requests alive until their applied, denied, expired, or cancelled result can be returned to the requesting agent, and keeps that delegation out of nested Codex Code Mode calls. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains Keep open for normal maintainer handling. No introduced correctness or security defect was found: the patch releases Gateway serialization while the initiating tool waits for the exact approval outcome, and retains live authority checks through the final effect. Priority: P1 Review scores
Verification
How this fits togetherThe agent-facing OpenClaw tool sends delegated administrative requests to the Gateway system agent. The Gateway stages a persistent proposal, waits for an operator decision outside its serialized task lane, then applies or rejects it and returns the resulting reply to the original tool call. flowchart LR
A[Agent tool call] --> B[Gateway chat request]
B --> C[Pending approval owner]
C --> D[Operator decision or cancellation]
D --> E[Live authority check and apply]
E --> F[Reply to original tool call]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +5, Tests +296, Docs +18. Total +319 across 18 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one approval-completion owner that releases the Gateway queue, returns the actual outcome to the initiating tool, and revalidates live authority immediately before application. Do we have a high-confidence way to reproduce the issue? Yes: the source identifies the pending-approval queue/lifetime path and the PR records authenticated Allow, Deny, Stop, and expiry scenarios, though this read-only review did not re-execute them. Is this the best way to solve the issue? Yes: moving the wait outside the serialized Gateway task while retaining the exact completion and final-effect authority assertions is the clean owner-boundary repair; keeping the tool direct-only matches the inspected Codex exposure contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d1774564e686. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
ClawSweeper evidence-gap resolutionThe completed ClawSweeper review found no correctness or security defects and rated the patch/proof diamond. Its P1 pre-merge item was a verification-access gap in its DNS-disabled environment. I verified each missing item before proceeding:
This resolves the published evidence-access concern through maintainer verification; it does not claim the review worker had network access. No code, authorization policy, or gate was weakened. Head remains |
|
Merged via squash.
|
) Wait for the actual delegated OpenClaw approval/application result without holding system-agent serialization or extending closed-run authority. Keep human approval on a direct model tool call so yielded Code Mode cells cannot strand it. Preserve cancellation and truthful denial/expiry results. Verified real authenticated Allow after 95 seconds, Deny, Stop, and natural 600-second expiry; late approvals preserve terminal state and perform no write. Related: openclaw#134557. No configuration, SQLite, or protocol changes.
|
I can confirm this failure remains present in the packaged stable release 2026.9.1 (ad6fe23) on Ubuntu. From a WhatsApp-backed Durable
They were cancelled roughly 8 s and 34 s after creation, despite their nominal 10-minute TTL. There were no matching The system-agent owner, WhatsApp allowlist, source session, and paired Control UI operator scopes were valid. This rules out a local routing/allowlist issue and matches the requesting-turn lifetime problem addressed by this PR. No secrets or personal identifiers included. |
Related: #134557 — delegated system-agent approvals can be consumed without applying the requested configuration change.
What Problem This Solves
Fixes an issue where users approving a delegated OpenClaw configuration change in Guarded mode could lose the approval card when the requesting turn finished, while the final answer incorrectly said the proposal was still pending for ten minutes. Even a quick Allow could record the human decision without applying the change.
Fresh authenticated baseline proof captured the full resolution payload:
deny,terminalStatus: cancelled, durable reasonrun-aborted. A separate actual Allow recordedallow-once, followed by a false-pending final andapplicationStatus: not-applied. This behavior already exists in baseline04bad80b953d493882d5ecf8b095275eaf5826fd; this PR does not attribute it to #136036, the Full Access delegation repair.Why This Change Was Made
The existing pending-proposal owner now carries completion, and the requesting tool waits for the actual application or terminal non-application result. Human waiting happens outside system-agent serialization so the single decision executor can reenter that queue without deadlocking. Final history and failure/cancellation/expiry replies come from that owner; the redundant per-session queue and immediate pending-response plumbing are removed.
Long real waits also exposed a native Code Mode ownership mismatch: a yielded cell could let the model finish its turn while the nested delegation call remained pending. The delegate now uses the existing direct-only tool surface, preserving one direct model call through the human decision. Other tools retain Code Mode, and ordinary tool policy, Codex exclusions, and turn allowlists still apply. Direct placement grants no ring-zero authority.
Authorization is unchanged: the exact run, tool, worker claim, Gateway, and session must remain live, including after awaited work and immediately before persistent effects. The caller now carries its individual AbortSignal privately instead of relying on an outer Promise race. A closed run cannot approve or revive the proposal. The approval still expires after 600 seconds; the dynamic tool uses the existing human-interaction execution budget and transport grace, not a new configuration option.
User Impact
Operators can take time to review a delegated change, click Allow or Deny, and receive the actual outcome. Stop cancels the proposal. Expiry produces a truthful final response instead of a disappearing card followed by a stale pending claim. Late Allow preserves the terminal decision and performs no write.
No new configuration keys, SQLite changes, protocol version, dependency changes, or compatibility fallback. Documentation is updated for OpenClaw delegation, permission modes, and the Codex harness reference.
Evidence
Real authenticated browser proof
Real isolated Gateway and Chromium, stock Codex 0.152.1, public
openai/gpt-5.6-luna, Guarded sessions. No provider mock, shortened expiry, clock manipulation, approval-manager injection, or operator Gateway/state access.logging.levelchangeddebug→info.chat.abort; durable cancelled record, aborted chat, visible “Interrupted”; no write.Deny and Stop completed while another session continued its full expiry wait. Late Allow after Deny, Stop, and expiry returned
applied: falsewith the exact unchanged terminal snapshot; saved/live configuration remained unchanged. This is the existing terminal replay contract, not an exception-based API.Before/after screenshots and recordings attached below were inspected and contain synthetic data only. Full resolution payloads, config readbacks, source hashes, build identity, and verification logs are retained locally. The live proof build is
2026.8.1-2d23e7276db1-2026-09-03T03-33-24.827Z; source/build hashes were unchanged throughout. The approval-owner modules are unchanged on the refreshed main baseline. Exact-head integration CI is tracked on this PR.Regression and contract proof
pnpm build qaRuntime; andgit diff --checkpassed. Documentation link audit: 7,290 links, zero broken.Focused owner command:
Native dependency source was inspected personally at Codex
rust-v0.152.1/5adb68a49933ae446bf11935662c83dba55a0804: direct-only exposure, namespace override, dynamic handler awaiting lines 139–151/174–250, and active-turn waiter cleanup. No custom Codex runtime or protocol is required.Scope and remaining distinctions
Production +361/−356, net +5; tests +975/−679, net +296, including moved authority coverage; docs +29/−11, net +18. Handler churn is largely dedentation after deleting duplicate serialization. Remaining production growth supplies the completion/ownership boundary and truthful terminal outcomes rather than a second execution path.
The baseline UI startup gzip guard failed by 143 bytes before any UI edits; the shared main repair #136817 has since merged. This PR changes no UI budget. The
ask_user/secretsCode Mode exposure audit is a separate follow-up, not silently included here. The issue's distinctagents.entriesdeletion/whole-object examples have not been reproduced by this proof, so the mutation-specific follow-up on #134557 remains for separate verification.Exact-head integration proof
Refreshed all four authenticated real-browser flows on PR head
72c297aee646c33d300808981628679ae6526d24, build2026.8.1-72c297aee646-2026-09-03T05-13-22.910Z, after integrating current main. Source/build hashes stayed unchanged throughout.logging.levelchanged fromdebugtoinfo.Late Allow after Deny, Stop, and expiry returned
applied: falsewith the exact unchanged terminal snapshot. Deny/Stop completed while the other session remained waiting. No model/provider mocks, clock shortcuts, or post-closure execution. Test Gateway/state and temporary credentials were cleaned up; the operator Gateway was untouched.The exact-head conversation-only recordings appended last show Allow and natural expiry, in that order. They were cropped to exclude operator identity chrome, then inspected across the full duration and final frames; the approval controls, countdown, final response and permission posture remain visible.
CI run 33717961345, attempt 1 completed successfully for the exact head; required
openclaw/ci-gateis SUCCESS, with no failed or pending checks. Local integration: 239 tests passed across three shards;pnpm build qaRuntimepassed in 3m38.4s after the frozen-lockfile install. Fresh pre-commit Codex autoreview was scoped-clean at P0-only threshold, andgit range-diffconfirms the rebase preserved the reviewed patch.Exact local test command:
ClawSweeper evidence-gap resolution
The completed ClawSweeper review found no correctness or security defects and rated the patch/proof diamond. Its P1 pre-merge item was a verification-access gap in its DNS-disabled environment. I verified each missing item before proceeding:
13799ec4f8380c14f7ce1836ce611291254bdda2and reopened all seven affected production modules. Each is byte-identical to the reviewed pre-fix baseline atc7f353d7274f130603d3af24f454218832025d66; the repair is not already present on main.git ls-remoteagainsthttps://github.com/openai/codex.gitreturned tag object3c6cfbab81e44218c729dc8c6b304cb760d1b8a1forrust-v0.152.1and peeled commit5adb68a49933ae446bf11935662c83dba55a0804, exactly matching the locally inspected source. The direct-call, waiter-cleanup and DirectModelOnly contracts cited above are from that commit.b978384507c1a484ed4c33c2d049d0786d1599303c5bbd13ba417e619112c48f; expiry isf39ac722d38beaf4faa11f0dce814eb879f39d69861f5bf343a6e0398ce49a3e.This resolves the published evidence-access concern through maintainer verification; it does not claim the review worker had network access. No code, authorization policy, or gate was weakened. Head remains
72c297aee646c33d300808981628679ae6526d24; exact-head CI, the required gate, independent review, and the four authenticated live flows remain green. No additional Rank-up moves or source findings were published.attachment-3921694616.webm
attachment-4180251352.webm
attachment-1393740255.mp4
attachment-811066557.mp4