Skip to content

fix: let hooks start the first agent session - #201103

Merged
VACInc merged 2 commits into
mainfrom
openclaw/good-langoustine
Nov 18, 2026
Merged

VACInc merged 2 commits into
mainfrom
openclaw/good-langoustine

Conversation

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The first authenticated /hooks/agent request for a fresh agent can return HTTP 500 before the agent run starts. An earlier read that found no session database can leave behind an empty native database generation, which blocks the first session write while that reader is still retained.

User Impact

User impact: hooks can create the first session after an empty database read, without restarting the Gateway or releasing unrelated readers. No configuration, permission, schema, or migration changes are required.

Why This Change Was Made

Retire the completed empty native generation through the existing database owner. Keep its logical readers usable and preserve the guard against joining a genuinely pending opener. This extends the existing released-reader regression to cover a retained reader and verifies that it can read the newly written session.

The author simplification pass kept this at one existing lifecycle decision and one additional test variant: production +5 lines net, tests +1 line net. There is no new owner, state, helper, retry, or permission exception.

Evidence

The unchanged Night Clawer hook test now accepts an authenticated HTTP request and returns ok: true with a run ID on the installed repaired package. The previous installed-package replay returned HTTP 500 with Agent creation cannot capture another pending native opener.

  • The retained-reader regression fails on the unmodified base with that exact error, then passes with the fix. The previously supported released-reader case still passes.
  • All 31 creation-witness tests and 52 sibling lifecycle tests pass. Both changed reader cases pass again after the final test-cleanup adjustment.
  • Touched-file format/lint, core and infrastructure-test typechecks, full package build, and package integrity checks pass.
  • Actual unmodified l1/hooks-agent replay: installation passed in 14.559 seconds; hook acceptance passed in 9.679 seconds. Both runners exited, their process groups were absent, and the private test runtime was removed.

This proves hook admission and retained-reader database behavior, not a model response or external message delivery. The broader Night Clawer suite still has separately tracked failures. Local independent automated review was not run under this task's no-subagent constraint; author source review is complete, and hosted ClawSweeper review and exact-head CI remain to be checked.

Reproduction and source binding
  • Regression base: c8da4b7fbc408570a52f37529612a458a24acb5d.
  • Tested repair: f7b6f3f9b785bf919065049516d5d84b91426f53; tree 7e3eb3e8d08c274a25788474aafc1284b15da93a.
  • Installed failure replay: OpenClaw f3707dafb937ac631ea5aa24f195f6243d5f41e7. The relevant hook/native-owner implementation is unchanged from this revision to the regression base.
  • Night Clawer harness: bf08117ab026cb82262c657b9621cbe7d6ec218d, tree-identical to the integrated harness used by Core run 44258661435.
  • Canonical repaired package SHA-256: 0b2510d01a516514b35bd6a82e1455c6d5a309e0b1c00f71b6288ec254307b49.
  • Node 24.22.1; source and package identity verified by the unchanged Night Clawer collector.
  • Package creation completed successfully. Its UI build also reported size-budget warnings; this two-file database repair changes no UI assets or budget settings.

Regression command: node scripts/test-projects.mts src/state/openclaw-agent-execution.creation-witness.test.ts --maxWorkers=1.

Native replay: python3 scripts/qa.py core --source-root <repaired-checkout> --tarball <canonical-package> --runtime-root <private-runtime> --output <results> --evidence-dir <evidence> --test-id l1/hooks-agent.

Contributor: @VACInc.

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

roboclaw-bot and others added 2 commits November 18, 2026 09:07
Retire completed native reads that found no database, while preserving logical borrowers and pending-opener protection.

Co-authored-by: VACInc <[email protected]>
Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: e848074a-1ac7-8bc7-8f5f-bec901cb1222
@clawsweeper

clawsweeper Bot commented Nov 18, 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.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 18, 2026 09:14
@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. 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. 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 Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Retire completed database generations that found no file so retained readers do not block first-session creation.

Example: A retained reader finds no database for agent main, then an authenticated /hooks/agent request starts its first session.

  • Before: Session creation fails with “Agent creation cannot capture another pending native opener”.
  • After: The hook is accepted, and the retained reader can read the newly created session.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, minimal lifecycle repair with focused regression coverage and recorded installed-package hook verification.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR records an installed-package authenticated /hooks/agent replay on Node 24.22.1 returning ok:true with a run ID after the previously observed pending-opener HTTP 500. Its tested tree equals the reviewed tree; the storage regression additionally verifies retained-reader reuse. The linked harness was inaccessible to this reviewer, and no model-response or delivery proof is claimed.
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 authenticated hook request can fail before starting the first session for a fresh agent.
Reason: The maintainer-authored direction restores expected hook admission with a narrow shared-owner repair.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current first-session failure through the existing database lifecycle owner. No actionable correctness or security findings were identified; exact-head CI is still pending.

Priority: P2
Reviewed head: db64b6ab85018ee059e7dd6e993e28372e142115

Before merge

None.

Findings

None.

Agent review details

How this fits together

The agent database execution owner coordinates logical readers, native worker generations, and session creation; callers retain their references while the owner replaces an empty native generation.

flowchart TD
  A[Authenticated hook request] --> B[Hook agent dispatch]
  B --> C[Session writer]
  C --> D[Agent database execution owner]
  E[Retained session reader] --> D
  D --> F[Native database worker]
Loading

Technical review

Best possible solution:

Use the existing native-close path to retire completed empty generations while preserving logical borrowers and genuinely pending preparation.

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

Current main retains a successful absent-read generation, and creating admission rejects that generation; the PR records the matching installed-package failure and regression failure on the base, but this read-only review executed no target code.

Is this the best way to solve the issue?

The patch repairs the shared lifecycle owner directly and extends an existing regression without adding state, helpers, retries, or a hook-specific workaround.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native generation retirement and logical reader preservation keeps the original intent (31c35d5: The executor extraction preserved physical-store identity, accepted-work custody, and cleanup ordering; subsequent recovery work explicitly preserved logical borrowers while replacing native generations. The extraction does not establish the original introduction of the carried guard.)
  • Missing-store first-session regression keeps the original intent (827a749: The earlier repair prevented an empty generation from remaining idle after its last reader released; the new variant preserves that contract and covers a reader that remains retained.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Focused lifecycle repair: The introduced production hunk extends existing native retirement to completed absent reads, retaining the generation identity, close-in-progress, and pending-preparation checks. (src/state/openclaw-agent-execution-owner.ts:270, db64b6ab8501)
  • Current main still needs the repair: Fetched main retires the generation after a successful operation only when current.failure() is set; a successful absent read leaves the generation present, which the creating borrower rejects. (src/state/openclaw-agent-execution-owner.ts:270, 4f8b68e647af)
  • Distinct regression coverage: The existing released-reader regression now also retains the original reader across first-session creation and verifies that reader can read the written entry through the real storage worker. (src/state/openclaw-agent-execution.creation-witness.test.ts:567, db64b6ab8501)
  • Earlier repair and original intent: fix(storage): allow first session after missing-store reads #200306 fixed empty-generation retention after the last reader releases; this PR covers the remaining retained-reader case while preserving logical-reader liveness. (src/state/openclaw-agent-execution.creation-witness.test.ts:567, 827a749e2c66)
  • Installed-package hook verification: The full PR body records an authenticated installed-package l1/hooks-agent replay changing from HTTP 500 to ok:true with a run ID on Node 24.22.1, plus a red-on-base retained-reader regression. The tested commit and reviewed head have identical trees. The body explicitly relies on the pinned Night Clawer harness; its repository and linked run returned HTTP 404 to this review, preventing independent harness inspection. (db64b6ab8501)
  • Proof remains bound to the reviewed tree: Both the tested repair and reviewed head resolve to tree 7e3eb3e8d08c274a25788474aafc1284b15da93a. (db64b6ab8501)

Likely related people:

  • Peter Steinberger: Raw commit 31c35d5 adds src/state/openclaw-agent-execution-owner.ts:253 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 31c35d5f5b09; files: src/state/openclaw-agent-execution-owner.ts)
  • RoboClaw: Raw commit 97f27a6 adds src/state/openclaw-agent-execution-owner.ts:270 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 97f27a65b0a6; files: src/state/openclaw-agent-execution-owner.ts)

PR surface

Source +5, Tests +1. Total +6 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 1 19 18 +1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 25 19 +6

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: A concrete storage lifecycle defect blocks first hook sessions after retained missing-store reads, with a focused repair and limited trigger.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • 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.

Label justifications:

  • P2: A concrete storage lifecycle defect blocks first hook sessions after retained missing-store reads, with a focused repair and limited trigger.
  • 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.
  • 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.

Reviewed November 18, 2026, 4:30 AM ET / 09:30 UTC.

@VACInc
VACInc merged commit e25ad96 into main Nov 18, 2026
219 checks passed
@VACInc
VACInc deleted the openclaw/good-langoustine branch November 18, 2026 11:16
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
* fix: allow first hook session after empty database reads

Retire completed native reads that found no database, while preserving logical borrowers and pending-opener protection.

Co-authored-by: VACInc <[email protected]>

* fix: let hooks start the first agent session

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: e848074a-1ac7-8bc7-8f5f-bec901cb1222

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: VACInc <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
Retire completed absent native reads without dropping retained logical borrowers or pending-opener protection.

Companion audit: #201272 is selected next; no other later same-path or PR-reference fix exists in the pinned scan. Existing callers and fixture contracts remain unchanged.

Release adaptation: none in the reviewed patch. Parent regression reproduces the retained-reader failure; the complete two-fix cohort passes 69 tests across creation and writer admission. Broader release qualification remains pending.

(cherry picked from commit e25ad96)

Co-authored-by: VACInc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
Capture the inherited creation witness inside the admitted writer turn, check caller authority before and after capture, and release only the captured reference. Preserve queued cancellation and next-creator behavior.

Companion audit: follows #201103; no later same-path or PR-reference fix exists in the pinned scan. Existing startup and session-writer callers retain their current interfaces.

Release adaptation: none in the reviewed patch. Parent regression reproduces the retained-witness failure; both fixes pass 69 tests across creation and writer admission, with touched production and test type-aware lint and formatting green. Broader release qualification remains pending.

(cherry picked from commit 24c2e74)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
* fix: allow first hook session after empty database reads

Retire completed native reads that found no database, while preserving logical borrowers and pending-opener protection.

Co-authored-by: VACInc <[email protected]>

* fix: let hooks start the first agent session

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: e848074a-1ac7-8bc7-8f5f-bec901cb1222

---------

Co-authored-by: VACInc <[email protected]>

(cherry picked from commit e25ad96)

Release adaptation: Source backport applied without production adaptation; retained focused regressions. Proof logs and exact setup/failure gaps recorded per assessment; pending independent review.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: XS 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