Skip to content

fix: accepted subagent results fail while the parent is busy - #177618

Closed
enki wants to merge 2 commits into
openclaw:mainfrom
enki:fix/requester-continuation-before-acceptance-20261019
Closed

enki wants to merge 2 commits into
openclaw:mainfrom
enki:fix/requester-continuation-before-acceptance-20261019

Conversation

@enki

@enki enki commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Related: #147499, #168068

What Problem This Solves

Fixes accepted subagent results failing to resume the parent when its turn is still busy.

User Impact

An accepted queued requester continuation owns its admitted automation authority for that exact run, independently of the originating invocation and later child-outbox cleanup. Cancellation, reset, source revocation, and requester restrictions remain enforced. No configuration or schema migration is required.

Why This Change Was Made

Transfer the existing one-use grant to its exact run scope before acknowledging acceptance. Dispatch reuses that scope; abort and cleanup revoke it even if execution never starts. Direct operator scope creation keeps its existing timing.

This is separate from #177564, which orders native recovery binding writes.

Evidence

  • A synthetic Gateway regression holds a real predecessor turn, waits for continuation acceptance, retires the persisted child outbox and releases the cohort, then verifies that the continuation executes with its admitted management authority. It reproduces the scope-ownership error before the repair.
  • Before this upstream refresh: 45 tests across three core/Gateway suites, core production types plus three owning test graphs, scoped lint, formatting, and the runtime build passed. Current integration results are listed below.
  • The earlier five-file repair was deployed locally, with installed runtime identity and authenticated Gateway health verified. This upstream merge has not been deployed. The regression controls model execution and does not claim a native model round trip. Fixtures contain synthetic data only.

Current integration: conflict resolved

Current head e49f86789707e08ecd335e06536ec7e0a5ae92fa merges pinned upstream 9f662f896dcf3a7dea8f4a01d198024acab75bff. The admission conflict preserves upstream's awaited plugin-subagent registration and rejection, post-await revalidation, and exact admitted-context cleanup. Requester scope is still prepared before acceptance and released through the joined, idempotent caller cleanup. The obsolete post-acceptance scope resolver is not restored. The resolved admission owner matches the consolidation's reviewed 7ecc42f61a92 implementation; this standalone PR retains only its five-file repair.

  • Current focused checks: 114 tests across eight files pass, covering queued scope retention, requester reset/revocation, plugin registration, native completion, dispatch ownership and automation authority. All three owning test type graphs, scoped typed lint and formatting pass. A fresh independent P0–P2 review of the complete five-file candidate and its cleanup/dispatch/grant context found no actionable finding.
  • Runtime build: The canonical public runtime build succeeds and records this exact commit. Its UI report warns that startup JS is 318.1 KiB against a 317.5 KiB budget; build exit is 0. This is build evidence, not a new native conversation or deployment.
  • Inherited production-type failure: The candidate and an exact-source run of the pinned upstream base both exit 2 with the same 809 diagnostics and no additional candidate diagnostics. The traced browser DOM/JSX ingress is an upstream Gateway .test-support.ts import chain included by the production core project. The failure is preserved rather than hidden by configuration, dependency overrides or an ignore.

The proof mapping below is historical and source-qualified. At this head seven of the nine inspected authority/effect owners still match both the earlier allowed/role/model capture and reset capture exactly. Admission now contains the upstream lifecycle changes above. The store planner's other change affects an update-state flag, while the demonstrated remove branch remains unchanged. Reset's only file difference removes an obsolete plugin-hook argument; lifecycle mutation and guard ordering remain unchanged. These comparisons justify bounded reuse, not a claim that the refreshed standalone binary has completed the earlier native scenarios.

Related final-effect evidence (source-qualified)

The consolidation evidence includes a real queued continuation's native automation removal and complete stored-inventory readback. At its tested b0d7186baf5 revision, canonical queued cancellation and original-device revocation after ACK prevented continuation native input/removal and left the complete stores unchanged. At 139939f8165, actual non-owner role and model-policy changes likewise denied the exact queued run before native input, with all stored columns unchanged. A root audit independently rechecked the source map. The nine transfer/admission/dispatch/grant/tool/mutation owners were byte-identical to this PR's earlier 8b9fead79515 and d74fb6f38f20 revisions; the current seven-of-nine mapping and upstream differences are described above. Surrounding wake, retained-requester and reconnect code differs. These are matching-owner results from the combined revision, not a claim that this standalone binary was executed.

The reachable positive ordering is bound scope → queued ACK → original requester cleanup → allowed effect → normal final → natural outbox retirement. ACK is not delivery: the actual outbox remained dispatching until settlement. Existing tests explicitly remove old cohort rows to check bound-scope independence; they do not demonstrate a natural early-removal producer. A generic post-acceptance dispatch exception remains a separate, unproved path. No effect after early outbox deletion, isolated commit-stage refusal or security-owner approval is inferred.

Queued requester reset: production-path negative control

Canonical requester reset after queued acceptance (5c831c77681): After a genuine managed-child completion bound its requester scope and received a queued ACK, an authenticated sessions.reset completed before the original cleanup gate was manually released. The session ID stayed stable and its lifecycle revision changed, confirmed by a separate canonical readback. The exact original queued run canceled before provider/native input; no continuation user echo or automation removal occurred. Complete canonical inventories and all 18 stored columns across both cron rows remained unchanged immediately after reset and through cleanup.

The original requester had genuinely yielded, ending its initial native turn as interrupted; the managed child finished normally before queued acceptance. Normal teardown forwarded two SIGTERMs after the recorded native turn terminals, and both recorded native app servers exited 0/signal:null without kill/timeout fallback. Gateway/provider/state/launcher cleanup completed. Inference was scripted loopback with verified native 0.163 overriding source 0.162.1. The first collector failed because it incorrectly expected reset to replace the session ID; that failure remains preserved, and this corrected run independently verifies the lifecycle-revision contract. This is the reset negative control, not isolated cron-commit refusal, a positive effect after early outbox retirement, standalone-binary proof or security-owner approval.
The nine transfer/admission/dispatch/grant/tool/mutation owners and reset service were byte-identical between this capture and the earlier d74fb6f38f20; the current seven-of-nine mapping, reset-hook argument change and surrounding lifecycle differences are described above. This is qualified reuse of the combined runtime, not execution of the standalone PR binary.

Redacted synthetic reset receipt
{
  "sourceRevision": "5c831c7768161d4fb5258ce0f4430b8cfe078b39",
  "nativeVersion": "0.163.0",
  "sourceManifestNativeVersion": "0.162.1",
  "syntheticOnly": true,
  "scriptedLoopbackProvider": true,
  "explicitNativeOverride": true,
  "authenticatedPairedDeviceClients": true,
  "realManagedChildNormalFinal": true,
  "scopeBoundBeforeActualQueuedACK": true,
  "outboxDispatchingAtACK": true,
  "canonicalRequesterResetAfterQueuedACK": true,
  "resetACKBeforeManualCleanupRelease": true,
  "noOrdinaryPredecessorGateReleaseObserved": true,
  "existingSessionIdPreserved": true,
  "requesterLifecycleRevisionChanged": true,
  "canonicalDescribeMatchesResetLifecycle": true,
  "exactOriginalQueuedRunCancelled": true,
  "queuePhaseProviderNotStarted": true,
  "nativeInputRequestsAfterQueuedACK": 0,
  "continuationNativeUserEchoes": 0,
  "nativeDynamicCallsAfterQueuedACK": 0,
  "nativeAutomationRemovalCalls": 0,
  "initialRequesterYieldInterruptedNativeTurnBeforeQueuedACK": true,
  "managedChildNormalTerminalBeforeQueuedACK": true,
  "nativeTurnInterruptRequestsAfterQueuedACK": 0,
  "completeCanonicalCronInventoryUnchanged": true,
  "everyStoredCronColumnUnchanged": true,
  "storedRowsChecked": 2,
  "columnsPerStoredRow": 18,
  "recordedNativeAppServersJoinedExitZeroSignalNull": 2,
  "forwardedNativeSignals": 2,
  "forwardedSIGTERMsAfterRecordedNativeTerminals": true,
  "nativeKillOrTimeoutFallbacks": 0,
  "gatewayConfirmedStopped": true,
  "observedCleanupErrors": 0,
  "providerJoined": true,
  "ownedRuntimeStateRemoved": true,
  "preImportEnvironmentRemovedAfterCollectorJoin": true,
  "collectorExitCode": 0,
  "originalFailedCollectorPreserved": true,
  "originalCollectorQualified": false,
  "earlyOutboxRetirementPositiveProven": false,
  "isolatedCronCommitGuardProven": false,
  "standalonePRBinaryExecuted": false,
  "securityOwnerApprovalInferred": false
}

@clawsweeper

clawsweeper Bot commented Oct 19, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Bind a queued subagent continuation’s automation authority before acceptance and release it with that exact run.

Example: A parent is busy when its completed child queues a continuation to remove a disabled automation.

  • Before: Acceptance precedes authority transfer, so the queued continuation can lose its management authority.
  • After: The accepted continuation retains its bound authority until completion or cancellation.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused ownership repair with meaningful boundary coverage and qualified runtime final-effect evidence; the previous conflict requirement is satisfied.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Source-qualified combined-runtime receipts exercise a real Gateway queued continuation through native automation removal and show cancellation, device revocation, requester reset, and role/model changes preventing effects. They use synthetic state, scripted inference, and a disclosed native-version override. The current integration preserves the reviewed transfer and cleanup logic; the body distinguishes reused captures from execution of this standalone binary. Early outbox deletion is an explicit regression-test lifetime control, not a claimed healthy runtime ordering.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An accepted child result can fail to resume useful parent work while the parent is busy.
Reason: Restores the existing admitted-run ownership contract with a focused change; no new user option, persisted format, or permission category is introduced.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR fixes a current-main requester-authority lifetime bug. The previous merge conflict is resolved, and no actionable patch defect was found; the PR remains draft.

Priority: P2
Reviewed head: e49f86789707e08ecd335e06536ec7e0a5ae92fa

Before merge

  • Complete next step - When ready to proceed, mark this PR ready for review so its required CI can run.

Findings

None.

Agent review details

How this fits together

Subagent settlement submits a synthetic parent continuation through Gateway admission, which transfers authority into the exact queued run before dispatch and automation management.

flowchart TD
  A[Completed child] --> B[Requester authority owner]
  B --> C[Gateway admission]
  C --> D[Bound queued run]
  D --> E[Parent dispatch]
  E --> F[Guarded automation operation]
  D --> G[Cancellation and cleanup]
Loading

Technical review

Best possible solution:

Keep the focused pre-acceptance transfer using the existing requester authority owner and exact-run cleanup.

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

Current-main source exposes acceptance before requester scope transfer, and the supplied controller-bound regression targets that interval; this review did not execute it.

Is this the best way to solve the issue?

The patch repairs ownership at admission, reuses the exact scope at dispatch, and preserves existing authority checks without introducing another authority manager.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against a3267d4b57e8.

Provenance checked

  • Requester management handoff and dispatch scope issuance keeps the original intent (3ae3e4d: Transfer verified management entitlement through a committed cohort and let the admitted successor own its fresh grants.)
  • Pause versus final-continuation release keeps the original intent (d023e9f: Pause notices retain cohort custody for later completion while their individual turns own separate scopes.)
  • Upstream admission and rejection cleanup keeps the original intent (bc3092f: Preserve durable accepted input and current execution authority through preparation, replacement, and cleanup.)
  • Existing authority test suite keeps the original intent (4aa7b50: Consolidate fixtures while retaining distinct lifecycle, authority, ordering, and failure cases.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3ae3e4d adds src/agents/subagents/requester-cron-authority.ts:352 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3ae3e4dc88ed; files: src/agents/subagents/requester-cron-authority.ts)
  • Vito Cappello: Raw commit 9c5a1c3 adds src/agents/subagents/requester-cron-authority.ts:531 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9c5a1c3c9cf7; files: src/agents/subagents/requester-cron-authority.ts)
  • Josh Avant: Raw commit bc3092f adds src/gateway/agent-turn/agent-run-admission-phase.ts:595 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc3092fceb5d; files: src/gateway/agent-turn/agent-run-admission-phase.ts)

PR surface

Source +61, Tests +88. Total +149 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 96 35 +61
Tests 1 96 8 +88
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 192 43 +149

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded queued-continuation lifetime bug can prevent a parent from finishing accepted automation work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-19T19:20:37.320Z sha 8b9fead7951556cbcca6a278600544f23018ff30 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-20T08:57:58.095Z sha d74fb6f :: needs changes before merge. :: none
  • reviewed 2026-10-20T09:07:09.181Z sha d74fb6f :: needs changes before merge. :: none

Reviewed October 20, 2026, 5:47 AM ET / 09:47 UTC (Revision 4).

@enki
enki force-pushed the fix/requester-continuation-before-acceptance-20261019 branch from 8b9fead to d74fb6f Compare October 19, 2026 23:23
@enki

enki commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The body now includes allowed queued automation removal and the nearest forbidden final-effect cases: queued cancellation, original-device revocation, requester reset, and role/model-policy changes. The new reset capture exercises actual queued acceptance followed by authenticated sessions.reset: the exact accepted run is cancelled before native input, and both complete automation rows remain unchanged across all 18 columns. The first failed collector is preserved and explained; the corrected run passes with native processes joined and owned runtime state removed.

Please assess this as source-qualified combined-runtime evidence: the nine transfer/admission/dispatch/grant/tool/mutation owners and reset service match this PR's current d74fb6f, but surrounding lifecycle/authority code differs. The body explicitly discloses the native-version override, scripted inference, teardown signals, and lack of a standalone-binary run. It does not claim an isolated commit-stage denial, a positive effect after early outbox deletion, or security-owner approval. Existing exact-head regression/type/lint/build evidence remains identified separately.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@enki

enki commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The sole remaining author item in the completed review is addressed at e49f86789707e08ecd335e06536ec7e0a5ae92fa, merged with pinned upstream 9f662f896dcf3a7dea8f4a01d198024acab75bff. The admission resolution preserves main's plugin-subagent rejection/awaited registration, revalidation and exact-context cleanup alongside pre-ACK requester scope transfer and joined idempotent release. No late duplicate scope issuance is restored.

114 focused tests across eight files, all three owning test type graphs, scoped typed lint/format, the exact-commit public runtime build and fresh independent P0–P2 review pass. Production core types fail identically on the candidate and an actual exact-source base run: the same 809 diagnostics, no added candidate diagnostics, with the upstream browser test-support import chain identified. The successful build's UI startup-budget warning is also disclosed.

The body updates the proof map honestly: seven of nine inspected authority/effect owners remain byte-identical to the historical combined captures; admission has the preserved upstream lifecycle changes, the store difference affects update-state rather than the demonstrated removal, and reset differs only in an obsolete plugin-hook argument. Historical native evidence keeps its recorded revisions, runtime override and limitations; no new standalone-native run or deployment is claimed. Please assess the completed conflict integration and retain any concrete remaining requirement.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 20, 2026
@enki

enki commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by merged #177698 (landed commit f83b7ad).

The landed consolidation prepares and binds the exact requester run scope before acceptance, reuses it at dispatch, and releases it through joined cleanup. This incorporates the accepted-result authority-lifetime repair rather than leaving this PR as a required follow-up.

Closing this standalone alternative. Retained personal-tool requester selection remains a distinct proposal in #178750; that policy is not claimed merged here.

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

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant