Skip to content

fix: keep OpenClaw helper calls working across runtime changes - #166235

Merged
obviyus merged 1 commit into
openclaw:mainfrom
PollyBot13:fix/system-agent-helper-admission-139710
Oct 7, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
PollyBot13:fix/system-agent-helper-admission-139710

Conversation

@PollyBot13

@PollyBot13 PollyBot13 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139710 and its consolidated duplicate #166138.

What Problem This Solves

Fixes the OpenClaw helper rejecting calls when its caller was admitted on a different runtime generation, or a benign inventory reload lands before a second helper call.

User Impact

A regular agent can consult the helper on the helper's verified default route while retaining its own non-default selection, and can consult it again after a benign reload. Genuine route drift and closed caller authority still fail closed.

Why This Change Was Made

The in-process delegation boundary was carrying the caller's prepared generation and plugin inventory into an independently selected helper runtime. Clear both selection scopes using the existing paired re-admission utilities already used by the embedded runner. Caller identity, approval checks, invocation/lifecycle authority, cancellation and the parent's scopes remain intact. No new owner manager, retry loop, public API, provider/config change, or weakened freshness check.

Credit: XX441's earlier diagnosis and proposed prepared-scope boundary. The paired plugin-inventory boundary additionally addresses the retired-inventory failure exposed by the real reload replay. This is independent of #157801 and does not modify that author's branch. Error guidance is a separate companion fix; this patch does not claim arbitrary active-plugin drain recovery (#160122).

Evidence

  • Test-first regressions fail on missing detachment: baseline retains the prepared generation; the prepared-only candidate still retains the plugin registry/cache. The final single regression asserts both selection scopes are absent during dispatch, caller approval/cancellation fences remain, and parent scopes restore after two calls.
  • Final maintained-wrapper focused suite: 104/104 passed across six files in 63.47s, including stale-owner/closed-lease rejection, caller-context narrowing, plugin-scope restoration and final-effect approval fences.
  • Isolated built-Gateway before/after on Node 24.21.0: real agent RPC → model-emitted openclaw tool → openclaw.chat → embedded helper → synthetic loopback provider → actual gateway_status result returned to caller. Same-owner non-default-provider baseline fails before helper dispatch; final candidate succeeds on the verified default provider.
  • A benign plugins.load.paths=[] hot reload is observed while the same caller is held after its first successful helper call. Baseline rejects the second call as superseded; prepared-only candidate rejects its retired inventory; final paired boundary completes both calls, with four helper provider requests and two distinct successful helper outputs.
  • Changing the verified model definition remains a negative control: the second helper is rejected before dispatch, not silently rebound to a changed route.
  • Independent adversarial native source/proof review accepted the exact final source/build fingerprints with no unresolved P0–P2 findings. Upstream CLI autoreview was attempted but unavailable (HTTP401); that attempt is not claimed as review coverage.
  • Maintained build-all.mts qaRuntime passed (37.8s). Full declaration/release packaging is not claimed.
  • Full changed-file check passed: core types, all 27 core-test type graphs, lint/format, ratchets, dead-export scans, runtime cycles and security-store guards.
Redacted real Gateway observations

The fixture uses maintained test-instance, Gateway client and Responses SSE helpers with disposable HOME/state, authenticated operator/device, fixture-only keys and synthetic loopback provider. No production Gateway or provider is used. The caller's same main session switches from openai/proof-default to bundled litellm/proof-override; the helper remains on the verified default.

baseline c10679395819ede78bb073f979f95c157e165bfa
  stable same-owner helper: actual Gateway status returned
  non-default caller: helper requests=0; tool error
  cause: prepared model runtime plugin generation was superseded for <agent-dir>

final paired boundary
  caller remains litellm/proof-override
  helper requests=2 on openai/proof-default; Gateway status returned

active same caller + benign plugin reload
  first helper returned Gateway status; caller held
  config hash changed; source revision accepted
  log: config hot reload applied (plugins.load)
  caller released; requests 14–15 are SECOND helper exchange
  request 16 contains two successful helper outputs
  helper requests=4; helper/caller tool errors=false

model-definition drift negative
  publication/hash change observed
  second helper dispatch=0; caller tool error (fail-closed)

all final runs: Gateway PID dead; provider listener closed; state removed

Final production source SHA-256: 99b2ddb997efa1c0b2498f76f05a2e6f0fb56cf9c7af27faae4178224ea02df8. Proof was captured from these source-identical precommit bytes; Git commit metadata changes no tested source. agent.wait.status=ok alone is not used as evidence of helper success.

Live proof covers synthetic provider transport and read-only Gateway status. Mutating final effects/live cancellation were not exercised in the Gateway fixture; focused approval/cancellation tests cover those fences. The benign reload fixture disables bundled plugins and does not establish active-plugin drain recovery.

CI baseline refresh — October 7

Rebased the unchanged patch from 88225457d9563d9c0b675162bb9f2fbd0f952449 onto main 0d06bc0fec0129608ed04ed286e7e1e2c28021e3, which includes the merged MCP dependency repair #166217. Refreshed head: 3e3fb3208df892c8dd328f3ac089fe191795edd7. An independent Astra review verified identical per-parent patches and every PR-owned source/test blob, with no refresh-induced finding. No manifest, lockfile or audit-policy change is added by this PR.

  • The production audit against the refreshed lockfile reports no matching high-or-higher npm bulk advisories; this is not comprehensive vulnerability clearance.
  • Supported node scripts/run-vitest.mjs focused regressions/controls: 108/108 passed (35.78 + 19.95 s). These local runs reuse the pre-refresh installed SDK 1.30.1/fs-safe 0.24.0 snapshot and supplement source validation, not clean-install compatibility. Hosted CI must validate the tracked SDK 1.31.0/fs-safe 0.24.1 dependencies.
  • Earlier Gateway traces and per-file timing evidence above are historical, source-identical proof, not a new current-head E2E replay. Fresh exact-head hosted CI and ClawSweeper review remain pending.

Owner acceptance: one two-file helper-admission boundary fix, reusing established utilities and existing fixtures. Rollback is reverting this patch. No persistent-data migration; no replay of already applied operations.

AI-assisted: implementation, synthetic fixture and independent review assisted by Codex.

Maintainer verification — October 7

No overlap with Pash/Sarah changes.

Rebuilt exact head 3e3fb3208df892c8dd328f3ac089fe191795edd7 in isolated Node 24 Docker (qaRuntime, 44.3 s). A candidate Gateway accepted a synthetic non-default caller, executed its openclaw delegation, and returned LIVE_HELPER_READY from one real gpt-5-mini Responses request (HTTP 200, 4096 output-token budget). The transport fixture set reasoning effort to low; caller and route-health responses were synthetic so only helper inference used the live provider. No mutating helper action is claimed. Gateway state was isolated on tmpfs and the provider credential was deleted afterward.

Current main 02e2078de7f634af018906abd7a43c3e275d5e25 has not touched either PR file since the candidate base; no base merge or source change was needed. Exact-head CI gate passes and ClawSweeper is ready.

@clawsweeper

clawsweeper Bot commented Oct 6, 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 agents Agent runtime and tooling size: S labels Oct 6, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 2:13 AM ET / 06:13 UTC (Revision 2).

ClawSweeper review

What this changes

The PR lets OpenClaw’s setup and repair helper select its own model runtime and plugin inventory while preserving caller permissions and cancellation, with regression coverage for repeated calls.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: pinned main and v2026.9.8 still inherit incompatible caller selection scopes. The focused repair has source-bound Gateway proof, and this review found no blocking defect or unresolved product choice.

Priority: P1
Reviewed head: 3e3fb3208df892c8dd328f3ac089fe191795edd7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair reuses established runtime boundaries and supplies convincing source-bound behavior proof without a blocking finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Source-matching built-Gateway traces exercise the changed delegation owner through actual helper inference and loopback HTTP transport: non-default callers succeed, repeated calls recover after benign inventory reload, and model-definition drift rejects before dispatch. Existing authority machinery is unchanged; mutating effects and active-plugin drain recovery are not claimed. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Source-matching built-Gateway traces exercise the changed delegation owner through actual helper inference and loopback HTTP transport: non-default callers succeed, repeated calls recover after benign inventory reload, and model-definition drift rejects before dispatch. Existing authority machinery is unchanged; mutating effects and active-plugin drain recovery are not claimed. No stored-data contract changes.
Evidence reviewed 10 items Verified introduced patch: The pinned base-to-head patch changes only delegation-boundary scope composition and its regression test. Caller identity, RPC arguments, permission calculation and result handling remain unchanged.
Still necessary on main: Pinned main dispatches openclaw.chat directly inside the caller context without clearing either inherited selection scope. The existing lease owner rejects incompatible inherited generations rather than silently changing their identity.
Latest supplied release lacks the fix: The v2026.9.8 delegation tool also dispatches directly without the paired scope detachment; the requested repair is not present in that release.
Findings None None.
Security None None.

How this fits together

Regular agents invoke the built-in OpenClaw helper through the Gateway for setup and repair. The helper verifies its own inference route and returns a reply or approval outcome to the calling agent.

flowchart TD
  A[Regular agent request] --> B[Delegation tool]
  B --> C[Preserve caller authority]
  C --> D[Clear caller selection scopes]
  D --> E[Gateway helper admission]
  E --> F[Verified helper runtime]
  F --> G[Reply or approval outcome]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +7, Tests +75. Total +82 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 19 12 +7
Tests 1 75 0 +75
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 94 12 +82

Review metrics

None.

Technical review

Best possible solution:

Keep helper runtime selection independent of its caller while retaining the existing verified-route, live-authority and cancellation guards.

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

Yes: source traces a caller's inherited generation into independently selected helper admission, where the lease rejects it; the contributor also supplies built-Gateway before/after observations. This reviewer did not execute a reproduction.

Is this the best way to solve the issue?

Yes: using the established paired scope utilities at the delegation boundary repairs selection ownership without weakening generation freshness or adding a competing runtime owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The repair addresses a broken built-in setup and repair helper workflow reported on the latest supplied official release.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Source-matching built-Gateway traces exercise the changed delegation owner through actual helper inference and loopback HTTP transport: non-default callers succeed, repeated calls recover after benign inventory reload, and model-definition drift rejects before dispatch. Existing authority machinery is unchanged; mutating effects and active-plugin drain recovery are not claimed. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Source-matching built-Gateway traces exercise the changed delegation owner through actual helper inference and loopback HTTP transport: non-default callers succeed, repeated calls recover after benign inventory reload, and model-definition drift rejects before dispatch. Existing authority machinery is unchanged; mutating effects and active-plugin drain recovery are not claimed. No stored-data contract changes.

Evidence

What I checked:

  • Verified introduced patch: The pinned base-to-head patch changes only delegation-boundary scope composition and its regression test. Caller identity, RPC arguments, permission calculation and result handling remain unchanged. (src/agents/tools/openclaw-delegate-tool.ts:140, 3e3fb3208df8)
  • Still necessary on main: Pinned main dispatches openclaw.chat directly inside the caller context without clearing either inherited selection scope. The existing lease owner rejects incompatible inherited generations rather than silently changing their identity. (src/agents/tools/openclaw-delegate-tool.ts:138, 0d06bc0fec01)
  • Latest supplied release lacks the fix: The v2026.9.8 delegation tool also dispatches directly without the paired scope detachment; the requested repair is not present in that release. (src/agents/tools/openclaw-delegate-tool.ts, fc23bc864e45)
  • Established re-admission pattern: The embedded runner already pairs these same two utilities during runtime refresh. The plugin utility removes metadata, cache and registry selection while preserving the authenticated Gateway scope. (src/agents/embedded-agent-runner/run-orchestrator.ts:649, 3e3fb3208df8)
  • Authority remains independently fenced: Same-run caller wrappers retain operator and approval authority, receipt checks, tool restrictions, Gateway binding and cancellation signals. In-process dispatch checks the captured caller before dispatch and after completion. The introduced utilities do not mint or transfer authority. (src/agents/tools/gateway-caller-context.ts:497, 3e3fb3208df8)
  • Real Gateway proof bound to production bytes: The captured PR body records Node 24.21.0 built-Gateway runs through agent RPC, a model-emitted openclaw tool call, actual helper admission and loopback provider HTTP inference. The baseline fails before helper dispatch; the paired fix returns actual Gateway status. After a benign plugin reload, four helper provider requests produce two successful helper outputs. Model-definition drift still rejects the second helper before dispatch. The inspected production SHA-256 exactly matches the recorded fingerprint 99b2ddb997efa1c0b2498f76f05a2e6f0fb56cf9c7af27faae4178224ea02df8. Captured context identity: 3922610627e49f31fab21154e05a20c877cd8941bfa682fdbdbfea392b21b352. Mutating final effects, live cancellation and active-plugin drain recovery are explicitly outside this trace's coverage. (src/agents/tools/openclaw-delegate-tool.ts:140, 3e3fb3208df8)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: 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 (1 earlier review cycle)
  • reviewed 2026-10-06T18:11:30.931Z sha 88225457d9563d9c0b675162bb9f2fbd0f952449 :: needs maintainer review before merge. :: none

@PollyBot13
PollyBot13 force-pushed the fix/system-agent-helper-admission-139710 branch from 8822545 to 3e3fb32 Compare October 7, 2026 06:07
@obviyus
obviyus merged commit d72a907 into openclaw:main Oct 7, 2026
135 of 137 checks passed
@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Landed in d72a907. Thanks @PollyBot13! Verified on a built Gateway: a caller on a non-default model and a second helper call after a benign reload were rejected on main and now succeed on the helper's own route, a changed model definition is still rejected, and a real gpt-5-mini helper call passed on this head.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…law#166235)

Let the OpenClaw helper run on its own verified default route when its caller was admitted on a different runtime generation or a benign inventory reload landed between calls, instead of rejecting the call. A genuinely changed model definition is still rejected.

Related: openclaw#139710

Co-authored-by: Ayaan Zaidi <[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 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. 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.

2 participants