Skip to content

fix(skills): run experience review outside released request roots - #116040

Merged
steipete merged 1 commit into
mainfrom
steipete/experience-review-gateway-admission
Jul 29, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/experience-review-gateway-admission

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

On a real gateway, the autonomous experience review never ran: every delayed review died with GatewayDrainingError: Gateway is draining; new tasks are not accepted on a healthy, running gateway, and the candidate was silently dropped (one WARN line, no retry). Self-learning's background review + auto-apply (#115576, #115887) was effectively non-functional in production.

Why This Change Was Made

The scheduler arms its idle timer inside the foreground run's agent-end side effects, which execute within the RPC's root-work admission AsyncLocalStorage context. Timer callbacks inherit that ALS context. By the time the 30s quiet timer fires, the request root is released, so isGatewaySubordinateWorkAdmissionClosed() returns current.released === true and the review's lane enqueue is refused. Unit tests inject runReview, and the vitest live eval calls runSkillExperienceReview directly with no ALS ancestor — both bypass the failing admission path, which is why this only surfaced under a real gateway.

The fix re-enters admission as independent root work (runWithGatewayIndependentRootWorkAdmission) around the review run — the documented seam for detached follow-up work. A genuine restart drain still refuses the review. Also adds debug-level experience review scheduled/skipped(reason) logging, which this investigation sorely missed.

User Impact

Self-learning experience reviews (and auto-mode applies) now actually run on live gateways. No config changes.

Evidence

  • Live repro on a scratch dev gateway (worktree build, native openai/gpt-5.6-luna runtime, real OpenAI key): before the fix, a 10+ iteration turn produced skill experience review failed: GatewayDrainingError ~60s after turn end, zero proposals. After the fix: three consecutive deep turns (sessions stress-s2/s3/s4) each produced a review, a pending proposal, and an auto-mode apply (skill_workshop_proposals rows applied, skills on disk), with zero review failures in the gateway log.
  • Regression test: experience-review-auto-apply.test.ts "re-enters gateway admission when fired from a released request root" — schedules the review from a released root-work ALS context and asserts isGatewaySubordinateWorkAdmissionClosed() is false inside the run (fails with GatewayDrainingError before the fix).
  • node scripts/run-vitest.mjs src/skills/workshop/experience-review.test.ts src/skills/workshop/experience-review-auto-apply.test.ts — 23 passed, on top of fix(agents): harden skill-review lane against cold-load stalls #115950.
  • node scripts/check-changed.mjs green locally (Blacksmith backend unreachable; documented trusted-source fallback) except a max-lines ratchet drift that resolved itself after rebasing onto latest main.
  • Autoreview (Codex gpt-5.6-sol): clean, no findings (0.94).

Live stress testing also surfaced two adjacent defects tracked separately: user aborts unwind the embedded run with a raw AbortError before any agent-end side effects (starving interrupted-turn review, autocapture, and plugin hooks), and terminal sessions from agent exec calls outlive their runs until the 24-session cap breaks exec gateway-wide.

@steipete
steipete marked this pull request as ready for review July 29, 2026 18:49
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 29, 2026
@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. P1 High-priority user-facing bug, regression, or broken workflow. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 2:53 PM ET / 18:53 UTC.

ClawSweeper review

What this changes

The PR runs delayed skill experience reviews under independent gateway-work admission, adds scheduler skip/schedule diagnostics, and tests the released-request-root case that previously rejected the review.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for explicit maintainer handling. The reported production failure is concrete, the patch is narrowly aimed at the detached gateway-work boundary, and the PR body provides before/after live-gateway evidence; however, the protected maintainer label prevents an automated cleanup outcome and the checkout could not be inspected locally to independently complete the required source/history audit.

Priority: P1
Reviewed head: 19e390f6bdadb5ff1b48f670032852cf6ec76945
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The PR presents a focused behavioral repair with concrete live-gateway results and targeted regression coverage, pending the protected maintainer lifecycle review.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body provides specific after-fix live-gateway results across three deep turns, including created proposals and auto-applied skill rows, alongside a focused released-root regression test.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides specific after-fix live-gateway results across three deep turns, including created proposals and auto-applied skill rows, alongside a focused released-root regression test.
Evidence reviewed 3 items Reported live behavior proof: The PR body documents a before/after real-gateway run: the released-root path previously produced GatewayDrainingError and no proposal, while three post-fix deep turns produced reviews, proposals, and auto-mode applies without review failures.
Focused regression coverage: The submitted test enters a root-work admission context, releases it, invokes the review, and asserts that the embedded run is no longer considered subordinate work under a closed admission context.
Related feature provenance: The affected autonomous experience-review and auto-apply workflow was introduced by merged self-learning work, including #115576 and #115887; this patch addresses a later-discovered execution-path failure in that workflow.
Findings None None.
Security None None.

How this fits together

After a sufficiently deep agent turn, the skill workshop scheduler waits for an idle interval and launches a detached experience-review run. That run passes through gateway work admission and the skill-review lane before it can create or automatically apply a skill proposal.

flowchart LR
  A[Foreground agent turn] --> B[Experience review scheduler]
  B --> C[Idle timer callback]
  C --> D[Gateway work admission]
  D --> E[Skill review lane]
  E --> F[Embedded reviewer]
  F --> G[Proposal or auto-apply]
Loading

Decision needed

Question Recommendation
Should this protected self-learning runtime fix be approved after confirming that independent-root admission still rejects work during an actual gateway drain? Confirm drain semantics and land: Verify the helper retains global draining rejection, then merge this narrow regression repair.

Why: The maintainer label requires explicit human handling, and the changed boundary controls whether detached work may begin during gateway lifecycle transitions.

Before merge

  • Resolve merge risk (P1) - The patch changes the admission boundary for detached background work, so the maintainer review should confirm that genuine gateway-drain refusal remains intact rather than only released request-root admission being bypassed.
  • Complete next step (P2) - The protected maintainer label and gateway-lifecycle boundary require explicit maintainer confirmation rather than automated repair or closure.
Agent review details

Security

None.

PR surface

Source +25, Tests +41. Total +66 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 25 0 +25
Tests 1 41 0 +41
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 66 0 +66

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused admission-boundary repair once a maintainer confirms the independent-root helper preserves real shutdown-drain refusal and the current head’s required checks finish successfully.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the focused admission-boundary repair once a maintainer confirms the independent-root helper preserves real shutdown-drain refusal and the current head’s required checks finish successfully.

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

No independently executed current-main reproduction was available in this read-only review, but the proposed regression test models the released root-work admission context described in the live gateway failure.

Is this the best way to solve the issue?

Unclear pending the required source-level lifecycle audit; re-entering independent root admission is a narrow plausible fix if it preserves genuine gateway-draining refusal.

AGENTS.md: unclear because the file could not be read completely.

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

Labels

Label changes:

  • add P1: The reported defect prevents a live background self-learning workflow from producing reviews or auto-applies on healthy gateways.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides specific after-fix live-gateway results across three deep turns, including created proposals and auto-applied skill rows, alongside a focused released-root regression test.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides specific after-fix live-gateway results across three deep turns, including created proposals and auto-applied skill rows, alongside a focused released-root regression test.

Label justifications:

  • P1: The reported defect prevents a live background self-learning workflow from producing reviews or auto-applies on healthy gateways.
  • 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 (live_output): The PR body provides specific after-fix live-gateway results across three deep turns, including created proposals and auto-applied skill rows, alongside a focused released-root regression test.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides specific after-fix live-gateway results across three deep turns, including created proposals and auto-applied skill rows, alongside a focused released-root regression test.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged self-learning default and interrupted-turn experience-review changes that established the affected scheduling and auto-apply workflow, then authored this focused repair. (role: feature owner; confidence: medium; commits: 8fd49c84aa2d, 095f30ae269d, 19e390f6bdad; files: src/skills/workshop/experience-review.ts, src/skills/workshop/experience-review-auto-apply.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm that the independent-root helper still rejects work during genuine gateway draining.
  • Let the remaining required checks complete on the reviewed head.

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.

@steipete
steipete merged commit 2366d35 into main Jul 29, 2026
178 of 193 checks passed
@steipete
steipete deleted the steipete/experience-review-gateway-admission branch July 29, 2026 19:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to sunlit-deng/openclaw that referenced this pull request Jul 29, 2026
* origin/main:
  fix(ui): explain unavailable MCP tool catalogs (openclaw#115994)
  fix(skills): run experience review outside released request roots (openclaw#116040)
  docs(security): add safe Gmail reader setup (openclaw#116041)
  chore: refresh browser gateway runtime (openclaw#116043)
  test: isolate gateway sequence lifecycle coverage
  docs: note gateway reconnect sequence fix
  test: cover gateway sequence reset on restart
  test: cover gateway sequence reset on reconnect
  fix: reset gateway event sequence on reconnect
vincentkoc added a commit to masatohoshino/openclaw that referenced this pull request Jul 29, 2026
* origin/main: (151 commits)
  feat(plugins): allow per-turn tool narrowing in prompt hooks (openclaw#114151)
  docs(hooks): mark pairing hook observation-only (openclaw#116055)
  docs(control-ui): document composer capability menu (openclaw#115858)
  fix(build): bound declaration memory use (openclaw#116021)
  fix: Slack replies recover after gateway startup replay (openclaw#115991)
  fix(azure-speech): keep valid voices from malformed catalogs (openclaw#115067)
  fix(agents): prevent model runtime startup timeout (openclaw#116039)
  fix(ui): explain unavailable MCP tool catalogs (openclaw#115994)
  fix(skills): run experience review outside released request roots (openclaw#116040)
  docs(security): add safe Gmail reader setup (openclaw#116041)
  chore: refresh browser gateway runtime (openclaw#116043)
  test: isolate gateway sequence lifecycle coverage
  docs: note gateway reconnect sequence fix
  test: cover gateway sequence reset on restart
  test: cover gateway sequence reset on reconnect
  fix: reset gateway event sequence on reconnect
  fix(codex): avoid transcript mirror snapshot churn (openclaw#115070)
  fix(test): stop cross-file state leaks in media suites (openclaw#116027)
  feat(hooks): add persistent hook session mode (openclaw#75918)
  fix(memory): return early for blank searches (openclaw#116034)
  ...
vincentkoc added a commit that referenced this pull request Jul 29, 2026
* origin/main: (39 commits)
  feat(apple): media renditions, Now Playing, video upload (#116051)
  feat(android): media renditions, MediaSession, video upload (#116037)
  feat(cli): run agent exec against the ambient config, composed in memory (#116038)
  fix #95351: [Feature]: Generic JSONL line-parsing hook for CliBackendPlugin (native tool-card support beyond claude-stream-json) (#95386)
  feat(plugins): allow per-turn tool narrowing in prompt hooks (#114151)
  docs(hooks): mark pairing hook observation-only (#116055)
  docs(control-ui): document composer capability menu (#115858)
  fix(build): bound declaration memory use (#116021)
  fix: Slack replies recover after gateway startup replay (#115991)
  fix(azure-speech): keep valid voices from malformed catalogs (#115067)
  fix(agents): prevent model runtime startup timeout (#116039)
  fix(ui): explain unavailable MCP tool catalogs (#115994)
  fix(skills): run experience review outside released request roots (#116040)
  docs(security): add safe Gmail reader setup (#116041)
  chore: refresh browser gateway runtime (#116043)
  test: isolate gateway sequence lifecycle coverage
  docs: note gateway reconnect sequence fix
  test: cover gateway sequence reset on restart
  test: cover gateway sequence reset on reconnect
  fix: reset gateway event sequence on reconnect
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR 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.

1 participant