Repository navigation
feat(hooks): add persistent hook session mode - #75918
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 2:25 PM ET / 18:25 UTC. ClawSweeper reviewWhat this changesAdds an opt-in Merge readinessKeep open for a maintainer product and security-boundary decision. The patch is a coherent, explicitly opt-in implementation with boundary-level proof, but it adds durable state reuse to public hook configuration and direct hook payloads; current main intentionally routes hook runs as isolated sessions. Priority: P2 Review scores
Verification
How this fits togetherGateway hooks accept authenticated HTTP webhook requests, validate their routing and session-key policy, then schedule an agent run through the cron-isolated runner. The runner’s session target determines whether the delivery starts a fresh context or resumes a stored conversation. flowchart LR
Webhook[Webhook delivery] --> Gateway[Gateway hook endpoint]
Gateway --> Policy[Session-key policy validation]
Policy --> Mapping[Direct or mapped hook action]
Mapping --> Dispatch[Agent-run dispatch]
Dispatch --> Target{Session target}
Target --> Isolated[Fresh isolated session]
Target --> Persistent[Existing keyed session]
Persistent --> Agent[Agent context and response]
Decision needed
Why: This is a new public capability and configuration contract that intentionally changes which persisted agent state a trusted webhook can resume; correctness tests cannot choose the repository’s desired authorization and operator model. Before merge
Agent review detailsSecurityNone. PR surfaceSource +84, Tests +466, Docs +11, Generated 0. Total +561 across 19 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Adopt the explicit opt-in mode only if maintainers accept its prefix-bound hook-key policy as the permanent boundary, then revalidate the rebased merge result with fresh-install and upgrade-safe configuration coverage. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main constructs hook jobs with an isolated session target, so repeated stable hook keys do not select a reusable agent session. The supplied PR proof then exercises the changed Gateway-to-runner boundary, although this review did not run a live provider. Is this the best way to solve the issue? Unclear. The explicit isolated-versus-persistent mode is the narrowest implementation shape found and avoids changing existing defaults, but maintainers must first decide whether the proposed hook-key policy is the right permanent authorization model for durable state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 97d374b357eb. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
3a9c98b to
597205b
Compare
597205b to
d3fc3f6
Compare
|
Thank you for this ryan. I know your last one went stale and was automatically closed. I hope this one makes it into a release! |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
@clawsweeper re-review Added stronger real behavior proof to the PR body:
The model call is mocked in the proof run so the evidence stays credential-free, but the gateway listener and hook HTTP dispatch path are real. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This pull request has been automatically marked as stale due to inactivity. |
* commit 'a47d81e7b33bf89c316a6aba857fafb0d5924167': fix(ui): derive cron timezone suggestions (openclaw#115973)
* commit 'e80fe942c8dae4b264acb2b501466224e842aa61': fix(gateway): stop start-time repair from retargeting managed services (openclaw#115935) fix(plugins): scope Codex relay with tool matchers (openclaw#109603) fix(discord): bound webhook send body reads (openclaw#109076) fix(ui): preserve initials for missing user avatars (openclaw#115976) feat(ui): add provider icons to coding catalogs (openclaw#115956) fix(daemon): refuse duplicate launchd gateway managers (openclaw#97285) fix(memory-lancedb): share the recall cooldown with the auto-recall prompt-build hook (openclaw#112927) fix(test): isolate plugin install fixtures (openclaw#116008) fix(feishu): guard Object.assign against prototype pollution in webhook payload merge (openclaw#111729) fix(sms): isolate validated webhook quotas per sender (openclaw#104862) fix(sessions): recover deleted chats without endless retries (openclaw#115974) fix(restart): log errors from restart hook callbacks instead of swallowing (openclaw#108847) feat(ui): enable tool-loop detection from Labs (openclaw#115983) fix(telegram): catch unhandled rejections in webhook and ingress worker shutdown (openclaw#100998) fix(memory): keep rollbacks compatible after recall metadata upgrade (openclaw#116003)
|
maintainer decision: accepted. the opt-in the exact head has fresh direct/mapped persistence, default-isolation, replay/admission proof and a green CI gate. proceeding through the repository prepare/merge validation. |
|
Merged via squash.
|
Fixes #11665.
Related admission work: #104712
What Problem This Solves
Hook agent calls always used isolated run sessions, so repeated webhook deliveries could not intentionally reuse conversation context even when an integration had a stable, scoped session key.
Why This Change Was Made
This adds an explicit
sessionMode: "isolated" | "persistent"contract for direct and mapped hook agent runs. Isolation remains the default. Persistent runs require a stable, policy-approved session key and reuse the existing cronsession:<key>target; this PR does not change the cron runner API or its general isolation behavior.The maintainer rewrite removes the original adjacent cron/session/auth changes and keeps ownership at the hook config, mapping, request-handler, and gateway dispatch boundaries.
User Impact
Trusted webhook integrations can opt into durable multi-turn hook sessions. Existing hooks remain isolated unless they explicitly request persistent mode.
Security behavior is fail-closed:
sessionKey,hooks.allowRequestSessionKey: true, and non-emptyhooks.allowedSessionKeyPrefixes.hooks.defaultSessionKey, or a transform that resolves a key at runtime.sessionModeis included in replay scope, so isolated and persistent deliveries cannot share an idempotency result.Evidence
Exact reviewed head:
016d95e340dd8c22009b6bfb0f874a8c302e4aa4Signed contributor rewrite:
2d0b77e8c764de1619036ad405a798e71dedfe33Signed prior current-main anchor:
36c6d4942a440cc498fd3222204868f54b5cddfcSigned maintainer validation fix:
8496b409f067b22828eef5bf22b235a21367957aSigned latest-main anchor:
ebf34d1230b635a2e593e67a4f71ae44a3236420Anchor baseline:
e80fe942c8dae4b264acb2b501466224e842aa61The anchor baseline contains the merged gateway admission change from #104712:
18fa771234f722e22da4d55f6e2113a5834d09ff814b9f6e36f3b2bfcf938f905a4c63b003314598git merge-base --is-ancestor 814b9f6e36f3b2bfcf938f905a4c63b003314598 e80fe942c8dae4b264acb2b501466224e842aa61passed.Composition with #104712 is additive: both direct and mapped requests still await
dispatchAgentHookWithReplay; persistent mode only selects the existingsession:<key>target after session-key policy validation. The admission tests prove simultaneous persistent duplicates share one pending admitted dispatch and retain the persistent target.{ "verdict": "pass", "headSha": "016d95e340dd8c22009b6bfb0f874a8c302e4aa4", "anchorBaseSha": "e80fe942c8dae4b264acb2b501466224e842aa61", "gatewayAdmissionMergeSha": "814b9f6e36f3b2bfcf938f905a4c63b003314598", "focusedTests": { "files": 5, "passed": 73, "failed": 0 }, "assertions": [ "isolated remains the default", "direct persistence requires an explicit bounded request key", "mapped persistence requires a stable key source", "persistent duplicates share one pending admitted dispatch", "session mode separates replay scope" ] }Exact-head validation:
node scripts/run-vitest.mjs src/config/config.hooks-session-mode.test.ts src/gateway/hooks.test.ts src/gateway/hooks-mapping.test.ts src/gateway/server.hooks-session-mode.test.ts src/gateway/server.hooks-admission.test.ts- 73 passed.node scripts/run-oxlint.mjs ...over all changed TypeScript files - passed.oxfmt --checkover all 20 changed files - passed.node --import tsx scripts/generate-config-doc-baseline.ts --check- passed.tsgolane vianode scripts/run-tsgo.mjs- passed.0.88.Workflow Sanitypassed, includingactionlint: https://github.com/openclaw/openclaw/actions/runs/30477071900Real behavior proofpassed with the authored problem/evidence sections: https://github.com/openclaw/openclaw/actions/runs/30477087269The current PR diff is 19 files,
+569/-8, and is based onmain.