Repository navigation
fix: Gateway stalls while background skill reviews or rooted cron jobs start - #164049
Conversation
…runs Rooted runs (skill workshop reviews in auto mode, cron jobs with an execution root) passed the execution root as workspaceDir, which also keyed the prepared model runtime and plugin metadata. No configured generation matched, so each run cold-built its own generation and cold-loaded tool plugins synchronously on the Gateway main thread (observed: 99 s prepared-runtime + 51 s plugin-tools, dropping websockets and a chat.send). When bootstrapWorkspaceDir resolves to the agent's canonical workspace, select the prepared runtime with that workspace and keep the run bound to its execution root. Compaction follows the same selection. Non-canonical or absent bootstrap workspaces keep their own generation.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 1:50 AM ET / 05:50 UTC (Revision 2). ClawSweeper reviewWhat this changesRooted background agent runs and compaction reuse the agent’s prepared plugins while keeping execution and file access confined to the task directory. Merge readiness✅ Ready for maintainer review The PR remains useful: current main still selects rooted runtimes by the execution workspace. The prior test-routing finding is fixed, and no blocking introduced defect was found. Likely related people: steipete and obviyus are routing candidates based on verified recent area commits; source-line introduction attribution remains unverified. Priority: P1 Review scores
Verification
How this fits togetherThe embedded agent runner prepares models, plugins, and tools for foreground turns and background jobs. Workspace selection determines which prepared runtime it uses, while sandbox preparation determines where the run can access files. flowchart TD
A[Background review or cron job] --> B[Resolve agent and bootstrap workspace]
B --> C{Canonical bootstrap workspace?}
C -->|Yes| D[Reuse prepared agent plugins]
C -->|No| E[Workspace scoped runtime]
D --> F[Execute within task root]
E --> F
F --> G[Rooted tools and compaction]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +66, Tests +297, Docs +2. Total +365 across 12 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the existing prepared-runtime owner for canonical plugin facts and retain the task root as the execution and filesystem boundary throughout runs and compaction. Do we have a high-confidence way to reproduce the issue? Yes: prepare the agent’s Gateway runtime, then invoke runEmbeddedAgent with a different execution root and canonical bootstrap workspace. Current main keys preparation by the execution root; supplied before/after evidence exercises this path, though this review did not execute it. Is this the best way to solve the issue? Yes: separating prepared plugin identity from execution workspace fixes the mismatched reuse key without adding a competing cache or changing filesystem policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against de14009aa222. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…space (#164594) Runs whose workspace was not the agent's canonical workspace (cron jobs, subagents, and other runs without a canonical bootstrap workspace) keyed their own prepared runtime and cold-loaded the whole plugin inventory synchronously on the Gateway main thread. In a Gateway every run workspace resolves to the same immutable boot inventory, so that generation was a duplicate of the configured one. These runs now borrow the agent's configured generation and keep their own execution workspace, the same selection #164049 introduced for rooted runs; compaction follows it. Plugin tool resolution also cold-loaded, on every turn, selected tool plugins that the prepared generation had already recorded as disabled or failed (for example memory-core outside the selected memory slot). Those records are settled loader outcomes and are no longer reloaded. Measured with forced [trace:embedded-run] stage summaries in a Gateway-shaped fixture: prepared-runtime 10627 ms -> 0 ms, worst main-thread block 10610 ms -> 15 ms, per-turn tool cold loads 2 -> 0.
…s start (openclaw#164049) * fix(agents): reuse the agent plugin generation for rooted background runs Rooted runs (skill workshop reviews in auto mode, cron jobs with an execution root) passed the execution root as workspaceDir, which also keyed the prepared model runtime and plugin metadata. No configured generation matched, so each run cold-built its own generation and cold-loaded tool plugins synchronously on the Gateway main thread (observed: 99 s prepared-runtime + 51 s plugin-tools, dropping websockets and a chat.send). When bootstrapWorkspaceDir resolves to the agent's canonical workspace, select the prepared runtime with that workspace and keep the run bound to its execution root. Compaction follows the same selection. Non-canonical or absent bootstrap workspaces keep their own generation. * test(agents): run the rooted prepared-runtime regression in the database worker lane
…space (openclaw#164594) Runs whose workspace was not the agent's canonical workspace (cron jobs, subagents, and other runs without a canonical bootstrap workspace) keyed their own prepared runtime and cold-loaded the whole plugin inventory synchronously on the Gateway main thread. In a Gateway every run workspace resolves to the same immutable boot inventory, so that generation was a duplicate of the configured one. These runs now borrow the agent's configured generation and keep their own execution workspace, the same selection openclaw#164049 introduced for rooted runs; compaction follows it. Plugin tool resolution also cold-loaded, on every turn, selected tool plugins that the prepared generation had already recorded as disabled or failed (for example memory-core outside the selected memory slot). Those records are settled loader outcomes and are no longer reloaded. Measured with forced [trace:embedded-run] stage summaries in a Gateway-shaped fixture: prepared-runtime 10627 ms -> 0 ms, worst main-thread block 10610 ms -> 15 ms, per-turn tool cold loads 2 -> 0.
…s start (openclaw#164049) * fix(agents): reuse the agent plugin generation for rooted background runs Rooted runs (skill workshop reviews in auto mode, cron jobs with an execution root) passed the execution root as workspaceDir, which also keyed the prepared model runtime and plugin metadata. No configured generation matched, so each run cold-built its own generation and cold-loaded tool plugins synchronously on the Gateway main thread (observed: 99 s prepared-runtime + 51 s plugin-tools, dropping websockets and a chat.send). When bootstrapWorkspaceDir resolves to the agent's canonical workspace, select the prepared runtime with that workspace and keep the run bound to its execution root. Compaction follows the same selection. Non-canonical or absent bootstrap workspaces keep their own generation. * test(agents): run the rooted prepared-runtime regression in the database worker lane (cherry picked from commit 0c96fd0) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes: the Gateway freezes for up to ~2.5 minutes (websockets drop, Control UI reconnects time out, a chat message typed meanwhile is never admitted) when a background Skill Workshop review or a cron job with an execution root starts.
User Impact
User impact: background Skill Workshop reviews (default
automode) and rooted cron jobs start in milliseconds on the agent's already-prepared plugins instead of rebuilding them on the Gateway main thread, so they no longer starve user-facing RPCs. Their file access stays confined to their execution root.Why This Change Was Made
Rooted runs pass their execution root (for example
<agentDir>/workshop-skills) as the run workspace. The orchestrator used that same directory as the identity of the prepared model runtime and plugin metadata, so it never matched the Gateway's configured generation and synchronously built a new one, then cold-loaded the tool plugins it lacked.Now, when the run's bootstrap workspace resolves to the agent's canonical (non-fallback) workspace, the prepared runtime and plugin metadata are selected with that canonical workspace, while the run keeps executing, sandboxing, and compacting in its execution root. Runs whose bootstrap workspace is absent or not canonical keep their own workspace-scoped generation, so no trust boundary widens. Existing lease reuse, supersession, and admission checks are unchanged.
Evidence
Production trace (single Gateway process,
isMainThread=true, oneskill-workshop-reviewrun; no log line from any subsystem during the first stall):Same reproduction before and after (real bundled plugins through
runEmbeddedAgentwith Gateway lifecycle active, stopping before inference):prepared-runtimeThe fixture's dynamic generation happened to include its tool plugin, so the production
plugin-toolscold load was not reproduced. After this change the rooted run binds to the same configured generation foreground turns use, and no foreground turn in the production log emitted a slowplugin-toolsstage.Regression:
run-orchestrator.rooted-proof.test.ts(“reuses configured plugins while keeping rooted file tools confined”) fails on the parent commit (generation identity assertion) and passes with the fix; it also proves the read tool reads inside the execution root and rejects a file in the canonical workspace.pnpm test src/agents/embedded-agent-runner/run-orchestrator.rooted-proof.test.ts --maxWorkers=1: 2.3 s test time, 29 s wall on a cold worktree (mostly transform). Unit coverage added for workspace selection (workspace-run.test.ts), binding (prepared-runtime-context.test.ts), and compaction (compact.sandbox-info.test.ts,compaction-runtime-context.test.ts).Locally: 769 tests across 52 affected files passed; production and test typechecks, lint, format, docs checks, import-cycle checks, and
pnpm buildpassed. Independent Codex autoreview (P1 threshold): scoped-clean.Release note: Gateway no longer stalls while background Skill Workshop reviews or rooted cron jobs prepare their runtime.