Skip to content

fix(agents): restore system-agent delegation in channel turns - #128084

Merged
VACInc merged 3 commits into
openclaw:mainfrom
VACInc:fix/isolated-probe-generation
Aug 23, 2026
Merged

VACInc merged 3 commits into
openclaw:mainfrom
VACInc:fix/isolated-probe-generation

Conversation

@VACInc

@VACInc VACInc commented Aug 23, 2026

Copy link
Copy Markdown
Member

Closes #128074

Summary

High Level TLDR

Fresh setup-inference probes launched from a channel turn inherited that turn's admitted plugin generation. The probe's intentionally isolated runtime snapshot then failed the generation guard before the delegate tool could reach the system agent. Isolated read-only runs now start without an ambient generation while ordinary nested runs and explicit generations retain their existing behavior.

Root Cause

runEmbeddedAgent fell back to the ambient AsyncLocalStorage plugin generation for every nested run. Channel reply execution establishes that scope, while setup inference intentionally acquires a separate read-only runtime snapshot. The existing owner guard correctly rejects metadata from a different snapshot, so the inherited generation made the probe fail at the runner boundary.

The focused pre-patch regression test reproduces the exact guard failure. Redacted live runtime records also showed delegate calls terminating at this guard before the patch.

Scope

  • Keep the existing generation behavior for normal nested runs and explicit caller-supplied generations.
  • Apply the exception at the embedded-runner owner, so both isolated-read-only callers share the same rule.

Verification

  • Pre-patch: node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.prepared-harness-source-delivery.integration.test.ts --testNamePattern='starts an isolated probe outside its caller' failed with prepared model runtime replaced the admitted plugin generation.
  • Post-patch: the same command passed.
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.prepared-harness-source-delivery.integration.test.ts — 11 passed.
  • pnpm check:changed — passed.
  • pnpm build — passed.
  • autoreview --mode local — no accepted/actionable findings.

Real behavior proof

I rebuilt and restarted the managed Gateway using the patched live checkout. The resulting embedded-agent bundle contains the isolated-read-only generation boundary, and the Gateway health check succeeded with the channel stack loaded. No external channel message was injected for this change, so the focused integration reproduction is the direct before/after proof.

What was not tested

  • No real external channel turn was sent during deployment.
  • A broader pnpm test:changed run was interrupted after its first two successful suite groups; it is not claimed as complete.

What Problem This Solves

Fixes an issue where users delegating to a system agent from a channel conversation could receive no delegate result when setup inference started an isolated probe.

Why This Change Was Made

The embedded runner owns the generation inheritance rule. Making isolated-read-only runs opt out there preserves the admission guard and avoids caller-specific scope workarounds.

User Impact

Delegated system-agent inference can complete from channel turns instead of failing before the delegate reaches the system agent.

Evidence

The regression test fails on the previous behavior at the same guard reported in the issue and passes with the patch. The exact candidate also passed changed-file checks, the focused integration suite, a production build, and local automated review.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Aug 23, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 1:33 AM ET / 05:33 UTC.

ClawSweeper review

What this changes

The PR stops isolated system-agent inference probes from inheriting a channel turn’s plugin-runtime generation and adds focused regression plus ephemeral-Gateway QA coverage.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: current main still unconditionally inherits the ambient generation, while this PR narrowly excludes it only for isolated read-only probes. No blocking patch defect found; exact-head CI and maintainer review remain before merge.

Priority: P1
Reviewed head: a5365ce666f99daa10905a1dc3cbfd0a6b9d22ef

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-boundary repair with credible focused and ephemeral-Gateway coverage; CI is still pending.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository context marks the author as a MEMBER, so the external-contributor proof gate does not apply; the PR still provides focused before/after boundary evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository context marks the author as a MEMBER, so the external-contributor proof gate does not apply; the PR still provides focused before/after boundary evidence.
Evidence reviewed 6 items Current-main gap: Current main always falls back to the ambient plugin generation when no explicit generation is supplied, including isolated read-only runs.
Owner-boundary repair: The branch preserves explicit generations and normal ambient inheritance, but omits only an ambient generation for isolated read-only runs.
Caller and guard: Setup inference explicitly requests isolated read-only mode, while the runner guard rejects an acquired snapshot that differs from an admitted generation.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw qa suite --provider-mode mock-openai --scenario system-agent-delegation-generation --concurrency 1 --fast

Result: FAIL (partial) — step 2 expect_output system-agent-delegation-generation: expected terminal output was not visible within 30 seconds: "system-agent-delegation-generation"

runner@runnervm76f27:/tmp/clawsweeper-live-proof-128084-L71gQ4/target$ pnpm openclaw qa suite --provider-mode mock-openai --scenario system-agent-delegation-gen
eration --concurrency 1 --fast
$ node scripts/run-node.mjs qa suite --provider-mode mock-openai --scenario system-agent-delegation-generation --concurrency 1 --fast
pnpm openclaw qa suite --provider-mode mock-openai --scenario system-agent-delegation-generation --concurrency 1 --fast
[openclaw] Building TypeScript (dist is stale: missing_private_qa_dist - private QA dist entry missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 101.51 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.6s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 12.3s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 3085ms (slowest: built plugin control-plane loads 2291ms)
│
◇

OpenClaw 2026.8.1 (a5365ce) — Hot reload for config, cold sweat for deploys.

[qa-suite] run start: scenarios=1 concurrency=1 transport=qa-channel
[qa-suite] lab start
[qa-suite] lab ready: ht
… output truncated …

Assertions:

  • FAIL expect_output: system-agent-delegation-generation
  • FAIL expect_output: PASS

How this fits together

Channel turns run an embedded agent under the runtime generation admitted by the Gateway. First-use system-agent delegation launches a separate read-only inference probe whose result returns through the delegate tool to the channel reply.

flowchart LR
A[Channel turn] --> B[Admitted runtime generation]
B --> C[Delegate tool]
C --> D[Isolated inference probe]
D --> E[Read-only runtime snapshot]
E --> F[System-agent result]
F --> G[Channel reply]
Loading

Before merge

  • Resolve merge risk (P1) - The net +5 production-line exception changes runtime-generation association; retain the mode-specific condition and require exact-head CI before merge.
Agent review details

Security

None.

PR surface

Source +11, Tests +64, Other +120. Total +195 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 12 1 +11
Tests 1 64 0 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 120 0 +120
Total 5 196 1 +195

Review metrics

Metric Value Why it matters
Production vs test LOC production net +5; tests +184; test support +6 The production change is one runner-mode selection; the remaining additions provide focused regression and channel-flow coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #128074
Summary: This PR is the linked candidate fix for the reported first-use system-agent delegate failure.

Members:

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

Merge-risk options

Maintainer options:

  1. Validate the mode-specific generation boundary (recommended)
    Merge after exact-head CI confirms isolated probes omit ambient generation while ordinary nested runs retain their admitted generation.

Technical review

Best possible solution:

Keep the generation distinction at the embedded-runner owner, with the focused guard regression and ephemeral-Gateway channel scenario protecting isolated probes without weakening ordinary admitted-generation propagation.

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

Yes: current main’s unconditional ambient fallback and the isolated caller/identity guard establish the failure path, while the focused regression constructs the distinct snapshots that trigger it.

Is this the best way to solve the issue?

Yes: the embedded runner owns ambient generation inheritance, and this condition preserves explicit generations plus normal nested runs while isolating only read-only probes.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The repair restores a channel-to-system-agent delegation workflow that can otherwise fail before the delegate executes.
  • merge-risk: 🚨 session-state: The patch changes how embedded runs associate with the generation admitted for a parent channel turn.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository context marks the author as a MEMBER, so the external-contributor proof gate does not apply; the PR still provides focused before/after boundary evidence.

Evidence

What I checked:

Likely related people:

  • VACInc: Authored the current repair and the previously merged generation-handoff PR identified in the supplied related-item history. (role: introduced behavior and prior adjacent repair; confidence: high; commits: ea57ebedaba7, 983782594807; files: src/agents/embedded-agent-runner/run-orchestrator.ts, src/agents/embedded-agent-runner/run.prepared-harness-source-delivery.integration.test.ts)
  • Vito Cappello: Current-head blame assigns the changed runner boundary to the merge commit. (role: current-head merger; confidence: medium; commits: a5365ce666f9; files: src/agents/embedded-agent-runner/run-orchestrator.ts)

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 (4 earlier review cycles)
  • reviewed 2026-08-23T02:32:59.315Z sha ea57ebe :: needs real behavior proof before merge. :: [P3] Document the isolated-generation boundary
  • reviewed 2026-08-23T03:15:30.135Z sha ea57ebe :: needs real behavior proof before merge. :: [P3] Document the isolated-generation boundary
  • reviewed 2026-08-23T04:45:23.407Z sha 67fef82 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T05:15:22.940Z sha 67fef82 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Aug 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added extensions: qa-lab maintainer Maintainer-authored PR labels Aug 23, 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 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 Aug 23, 2026
@VACInc
VACInc marked this pull request as ready for review August 23, 2026 05:10
@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 Aug 23, 2026
@VACInc
VACInc merged commit 967696b into openclaw:main Aug 23, 2026
253 checks passed
@VACInc
VACInc deleted the fix/isolated-probe-generation branch August 23, 2026 05:45
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
…aw#128084)

* fix(agents): isolate probe runtime generation

* test(qa): prove channel system-agent delegation

---------

Co-authored-by: VACInc <[email protected]>
Co-authored-by: RoboClaw <[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: qa-lab maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. 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.

[Bug]: openclaw delegate tool fails inside channel turns: inference probe inherits admitted plugin generation and trips the admission guard

2 participants