Skip to content

fix: preserve requester tools after subagents settle - #160786

Merged
joshavant merged 2 commits into
mainfrom
codex/qa-issue109025-settle-policy
Sep 29, 2026
Merged

joshavant merged 2 commits into
mainfrom
codex/qa-issue109025-settle-policy

Conversation

@joshavant

@joshavant joshavant commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #109025

What Problem This Solves

Fixes authorized tools disappearing when a yielded parent resumes after its children settle.

User Impact

The resumed requester retains the policy captured at spawn, including its existing restrictions. Revoked authority and stale requester sessions cannot restore access. Missing or conflicting child policies leave the continuation under its ordinary restricted policy. No configuration or migration is required.

Why This Change Was Made

Extend the existing completion capability and requester-policy owners to recognize settled continuations, bind them to the current requester and exact batch, and verify every child's persisted policy. Bind replay to the child source actually accepted by transcript admission. Reply-authority snapshots preserve the settle owner's live revocation check, and the existing tool source fence checks it again at final I/O. Direct announce behavior remains intact; no sender identity is synthesized.

Evidence

  • Before: on the base commit, the unchanged live scenario completed its child but the continuation lost exec (29 tools fell to 27), produced no proof file, and failed after 360 seconds.
  • After: after-snapshot restored 29 tools, created the proof marker, and sent the visible final. The unchanged scenario still failed its exact-once exec assertion.
  • Live limitation: one retained diagnostic established a harness false-negative: QA counted three exec successes from two Code Mode wrappers and one actual shell invocation. The wrappers spawned the child and invoked the shell; distinct correlated call IDs rule out a duplicated shell call in that replay. Its senderless settle continuation retained the child's versioned requester policy, permitting exec and denying write. A separate model quote-escape error made that diagnostic command exit 1; it does not contradict authority restoration. The coordinating session intentionally sent SIGINT after capturing decisive evidence, causing exit 130 to avoid the known harness timeout. No further replay ran, and neither the scenario nor product was changed to accommodate these harness/model failures. The earlier run's raw transcript is unavailable, so its physical exec count cannot be recovered.
  • Focused proof: 81 requester-policy, completion-capability, direct-handoff, and reply-authority tests passed in 22.89 seconds. Existing attempt/settle-dispatch/reply tests also passed. Coverage includes matching and conflicting batch policies, missing lineage, revocation before and after capability consumption, stale requester identity, external-sender denial, and snapshot revocation.
  • Hosted review follow-up: the hosted review initially identified accepted-source replay and final-effect revocation gaps. Both regressions failed on that head, then passed after fixing the existing owners. The real Gateway/SQLite admission test preserves an interrupted sibling's accepted source and binds the grant to it. The production exec runtime test passes through the tool caller wrapper and final supervisor guard: a current batch reaches the controlled effect once; revocation or reassignment after awaited preparation reaches it zero times. The physical process is mocked, so this is boundary proof, not another live model replay. All 135 tests across six focused files passed in 100.60 seconds with one worker. The earlier live observations precede these review fixes. ClawSweeper's automatic refresh reviewed final head 189d179f2798006b64728a6b941df9065e98c352, found no actionable findings, and marked it ready for maintainer review.
  • Production typecheck, the affected agents-tools and Gateway-server test typecheck graphs, focused lint/formatting, line-cap/assertion ratchets, and diff checks passed on the review fixes. Earlier docs lint also passed. The changed-check wrapper hits an inherited environment-variable budget mismatch (477 versus 476), reproduced against the unchanged index; this patch adds no environment variables. Broader test typechecking was not completed.
  • Added-test cost with pnpm test <file> --maxWorkers=1: requester-policy file 34.11 seconds including a cold worker build (about 1.7 seconds executing tests); capability file 3.23 seconds (0.12 seconds executing tests). After review, the exec-runtime file passed 31 tests in 31.62 seconds wall and the private-completion file passed 22 tests in 64.46 seconds wall, both including compilation. The new Gateway replay case took 1.85 seconds in the combined focused run; the three final-spawn cases took 11 ms total. Hosted summed case durations for the complete files were requester-policy 1.460 seconds (34 tests), capability 0.042 seconds (11), exec-runtime 0.262 seconds (31), and private-completion 24.833 seconds (22), excluding shared setup/build time.
  • Final-head CI: run 36498813903 succeeded with 115 passing jobs and 21 skipped jobs, no failures. The CI gate, dependency review, and security-sensitive review are successful on 189d179f2798006b64728a6b941df9065e98c352.
  • The canonical private-key command, node scripts/detect-private-keys.mts (owned by .pre-commit-config.yaml), was invoked once for the requested final-candidate verification on 189d179f2798006b64728a6b941df9065e98c352. It exited 0: 50,476 tracked files scanned, no private keys found. Diagnostic runtime and staged roots were removed through the QA cleanup owner; concise local evidence is preserved.
  • Ordinary autoreview gate: unavailable. The explicit campaign policy requires codex --yolo, which conflicts with the helper's isolation controls. The permitted Claude safe-mode fallback is concretely absent (executable not found: claude). No autoreview verdict was produced. No additional engine was tried and no isolation workaround was used in this resumed lane. The user explicitly authorized proceeding with this unavailable gate recorded.
  • Separate hosted review requirement: one explicit hosted exact-head ClawSweeper review was requested after push, and its automatic refresh cleared the final head as recorded above. This review does not substitute for or satisfy the unavailable ordinary autoreview gate. Its concrete findings were addressed; conflicting or legacy batch policies retain the restricted continuation, resolving the availability concern without a wider grant.

No merge, queue, or automerge is requested.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

Exact head: ea7becc43b62c4bca2762891ee26aa4229307fc2.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 8:04 PM ET / September 29, 2026, 00:04 UTC (Revision 3).

ClawSweeper review

What this changes

The branch preserves a requester's captured tool policy when its subagents settle, while binding the handoff to the admitted batch and checking revocation before tool effects.

Merge readiness

✅ Ready for maintainer review

Current main still lacks the settled-requester fix. The current head addresses the earlier replay-source finding, and this review found no discrete blocking defect.

Priority: P1
Reviewed head: 189d179f2798006b64728a6b941df9065e98c352

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused fix has meaningful live and boundary evidence, with the final authority changes covered by targeted regressions and no actionable finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR reports that the OpenClaw Gateway settle continuation regained its tool inventory, produced a proof marker, and sent a final reply in a live after-fix run. That run predates the final replay and guard changes; final-head Gateway/SQLite and process-boundary regressions cover those changes, although the process is mocked. No stored data-model contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports that the OpenClaw Gateway settle continuation regained its tool inventory, produced a proof marker, and sent a final reply in a live after-fix run. That run predates the final replay and guard changes; final-head Gateway/SQLite and process-boundary regressions cover those changes, although the process is mocked. No stored data-model contract changes.
Evidence reviewed 11 items Introduced branch surface: The pinned merge-base-to-head diff changes the completion capability, requester policy, replay admission, tool caller, focused tests, and subagent policy documentation.
Current main comparison: At the fetched main revision, the completion handoff and requester-policy files have no settle-batch handling; the branch retains a distinct fix.
Accepted replay source: Gateway consumes the one-use handoff after transcript admission selects the user turn's provenance, including a source from the registered settle cohort. This addresses the earlier review finding.
Findings None None.
Security None None.

How this fits together

Gateway admits subagent completion input and passes it to the agent runner. The runner selects tools under the requester's policy, and those tools can then perform process or file effects.

flowchart LR
  A[Settled subagents] --> B[Gateway replay admission]
  B --> C[One-use completion handoff]
  C --> D[Requester policy check]
  D --> E[Agent tools]
  E --> F[Guarded effects]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +82, Tests +263, Docs +8. Total +353 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 154 72 +82
Tests 4 265 2 +263
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 427 74 +353

Review metrics

None.

Technical review

Best possible solution:

Keep one completion-capability path that restores the captured requester policy only for an admitted, current batch and rechecks revocation at tool effects.

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

Yes. Current-main source and the reported baseline run give a high-confidence path: a requester with an exact sender tool override yields to children, then its settle continuation loses exec. I did not execute that path in this read-only review.

Is this the best way to solve the issue?

Yes. The patch extends the existing completion-capability and requester-policy owners, and the inspected path retains the ordinary restricted policy when batch evidence fails.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 91a86e494e86.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The reported failure removes authorized tools from an active delegated agent workflow.
  • merge-risk: 🚨 security-boundary: The patch changes when a senderless continuation receives requester-scoped tools, making its batch and final-effect checks security-relevant.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports that the OpenClaw Gateway settle continuation regained its tool inventory, produced a proof marker, and sent a final reply in a live after-fix run. That run predates the final replay and guard changes; final-head Gateway/SQLite and process-boundary regressions cover those changes, although the process is mocked. No stored data-model contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports that the OpenClaw Gateway settle continuation regained its tool inventory, produced a proof marker, and sent a final reply in a live after-fix run. That run predates the final replay and guard changes; final-head Gateway/SQLite and process-boundary regressions cover those changes, although the process is mocked. No stored data-model contract changes.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-28T23:23:24.135Z sha ea7becc :: needs real behavior proof before merge. :: [P1] Bind the handoff to the accepted replay source
  • reviewed 2026-09-28T23:45:41.979Z sha 189d179 :: needs maintainer review before merge. :: none

@joshavant
joshavant marked this pull request as ready for review September 28, 2026 23:35
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 189d179f2798006b64728a6b941df9065e98c352
  • Maintainer: @joshavant
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/requester-tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@joshavant
joshavant merged commit 27de2f8 into main Sep 29, 2026
290 of 292 checks passed
@joshavant
joshavant deleted the codex/qa-issue109025-settle-policy branch September 29, 2026 00:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
* fix: preserve requester tools after subagents settle

* fix: retain settled authority through replay and tool execution
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 gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: M 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.

1 participant