Repository navigation
fix(memory): preserve standing intents after prompt hook timeouts - #145107
Conversation
Give each before_prompt_build handler an ephemeral result-acceptance capability and revoke it when the runner stops awaiting that handler. Memory Core checks it after lazy loading and before its synchronous standing-intent effects, preserving live callers of a shared database open. Missing host support produces a diagnostic without consuming a reminder. Document the optional SDK capability and cover timed-out, settled, and coalesced callers. Underlying work retains its existing cleanup lifecycle. Related: #144832 Validation: 91 focused tests, selected changed checks, and independent P2 review.
|
🦞👀 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: blocked before merge. Reviewed September 11, 2026, 2:06 PM ET / 18:06 UTC (Revision 2). ClawSweeper reviewWhat this changesAdds a per-handler prompt-hook lifetime check so delayed Memory Core matching cannot consume a reminder after its hook times out, with regression tests and SDK documentation. Merge readiness⛔ Blocked before merge - 2 items remain This fix remains necessary on current main, and no actionable patch defects were found. The updated disposition resolves the prior compatibility and migration concerns. Priority: P2 Review scores
Verification
How this fits togetherMemory Core stores event-triggered reminders and matches them against incoming user prompts. Prompt hooks inject matching reminders into model context while updating their stored fire budgets. flowchart TD
A[User prompt] --> B[Prompt hook handler]
B --> C[Shared database admission]
C --> D{Handler still active?}
D -->|Yes| E[Match and update reminder budget]
E --> F[Reminder context for model]
D -->|No| G[Preserve reminder budget]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +37, Tests +296, Docs +28. Total +361 across 9 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Ship the paired host/plugin repair with handler lifetime owned by the runner and existing reminder storage and shared-admission semantics preserved. Do we have a high-confidence way to reproduce the issue? Yes, from source: hold database admission beyond the prompt-hook timeout, then resume matching; current main can still consume the fire after discarding the hook result. The registered-path regression covers this sequence, but was not rerun here. Is this the best way to solve the issue? Yes. The runner owns result eligibility, and Memory Core checks it immediately before synchronous effects without cancelling shared database work or changing stored formats. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 58a6953549d0. LabelsLabel 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)
|
Merge current main to pick up the existing daemon install test lint repair. The standing-intent patch against the merged main is byte-identical to the reviewed original; no new product changes.
|
Merged via squash.
|
…enclaw#145107) Give each before_prompt_build handler an ephemeral result-acceptance capability and revoke it when the runner stops awaiting that handler. Memory Core checks it after lazy loading and before its synchronous standing-intent effects, preserving live callers of a shared database open. Missing host support produces a diagnostic without consuming a reminder. Document the optional SDK capability and cover timed-out, settled, and coalesced callers. Underlying work retains its existing cleanup lifecycle. Related: openclaw#144832 Validation: 91 focused tests, selected changed checks, and independent P2 review.
Related: #144832, #116522
What Problem This Solves
Fixes an issue where a standing intent could spend a reminder fire after its prompt hook had timed out, leaving the reminder unavailable even though its context never reached that prompt.
Why This Change Was Made
The hook runner gives each
before_prompt_buildhandler its ownhookInvocation.assertActive()capability and expires it when that handler returns, rejects, or times out. Memory Core checks it after lazy loading and immediately before its synchronous database effects. Shared database admission and underlying work keep their existing ownership and cleanup.This is a scoped result-eligibility guard for ordinary and authorized prompt phases. The separate cooperative-cancellation proposal in #116522 remains open; this change does not address its broader cancellation and child-process lifecycle scope or close #115450.
User Impact
Late matching no longer consumes a standing-intent fire. A host without the required capability logs a clear diagnostic and skips matching without consuming the intent. The SDK field is optional for compatibility and grants neither tool authorization nor a guarantee of eventual model consumption.
Evidence
donewithfire_count: 1. It passes with the repair. All 91 focused tests across seven files pass, including configured short deadlines, stale-first/live-second handlers in both phases, missing-host diagnostics, and a live caller sharing cold admission.d3f34c5ce8ac504dfcfb3e454d83ae176b70c749executed 68 of the 91 focused cases across four files, including the registered-hook/SQLite timeout regression, missing-host diagnostic, live coalesced cold-open control, and all eight invocation cases. The remaining three unchanged plugin sibling files were verified locally. The standalone Testbox attempt stopped at provider status lookup before execution; its lease is closed and no standalone Linux result is claimed.Review Disposition
The host and Memory Core consumer are updated together in this PR; Memory Core is a private bundled plugin. Diagnostic skipping on an unsupported host is the intentional compatibility behavior, covered by the missing-capability regression and documented in the hook guide.
The data-model warning does not correspond to a stored-format change. The patch adds an invocation assertion before the existing standing-intent database callback; schema definitions, schema assurance, lifecycle SQL, claim SQL, row encoding, indexes, and migration versions are unchanged. Existing stored intents use the same database and transaction path when the handler remains active. No data migration is introduced or needed.
The controlled timeout regression proves the discarded-result/late-write invariant, not measured live Gateway latency. The first run failed an unrelated daemon-test file-length check on its synthetic merge base; main already repaired that check. The subsequent main integration leaves this PR’s full nine-file patch byte-identical to the reviewed original. Fresh Linux jobs passed again on the refreshed PR head: Memory Core and hook invocation. Both ran on Ubuntu 24.04.3 with Node 24.19.0, using synthetic merge
fbda7e2b322e7bd6c2eaac47232af4e57cacc002into main58a6953549d011ffe44dcc3a7f3290b50e64b349. No focused case was skipped. The failed standalone Testbox attempt remains unverified and is not counted as test evidence.