Repository navigation
fix: avoid database cleanup errors after temporary agent runs - #148674
Conversation
|
🦞👀 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 September 14, 2026, 9:31 PM ET / September 15, 2026, 01:31 UTC. ClawSweeper reviewWhat this changesTemporary agent runs now finish accepted database work and close their owned database resources before removing temporary state. Merge readiness✅ Ready for maintainer review The PR remains useful: current main and v2026.9.4 lack the temporary-run database drain. No blocking defect was found in the introduced changes. Priority: P2 Review scores
Verification
How this fits togetherThe agent exec command runs a single embedded agent turn and owns its temporary state directory. Database lifecycle scopes coordinate pending work, worker resources, and native handles before that directory is removed. flowchart TD
A[Agent exec invocation] --> B{Temporary state?}
B -->|Yes| C[Database resource scope]
B -->|No| D[Existing retained-state ownership]
C --> E[Agent turn and audit writes]
E --> F[Drain work and close owned resources]
F --> G{Cleanup confirmed?}
G -->|Yes| H[Remove temporary state]
G -->|No| I[Preserve state and report failure]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +27, Tests +136, Docs 0. Total +163 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep temporary-state deletion behind the existing resource owner's completed drain, preserving independent clients and retaining state whenever cleanup is uncertain. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main can remove temporary state without draining its database resources, and the supplied regression targets that ordering. No runtime reproduction was executed in this review. Is this the best way to solve the issue? Yes. Reusing the existing resource scope addresses ownership directly and preserves cleanup-error reporting, unlike retrying deletion or suppressing its failure. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 55e261df56a4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
Fixes database cleanup errors when
openclaw agent execremoves its temporary state while database workers still own resources there.User Impact
Temporary runs finish their database cleanup before removing state. Explicit
--state-dirownership and retained state are unchanged; uncertain runtime or process cleanup still preserves state for inspection. No configuration or schema migration is required.Why This Change Was Made
Temporary execution now uses the existing lexical database resource owner, which drains accepted work and closes the run’s exact resources before the environment is restored. Independent cached handles keep their existing owner. The scope distinguishes resource custody from schema maintenance and preserves real maintenance delegation through nested scopes.
Evidence
Both ordinary success/error regressions pass through the real command with a mocked agent, synthetic session creation/deletion, and an asynchronous audit write. They verify native handle closure before removal and preserve an independent database. Both fail on the original command because its temporary handles remain open; the control prevents deletion until test-owned cleanup runs.
The pure scope inheritance/delegation test and three retained-state/config-restoration checks pass. Fresh independent P2 review is clean. All changed-file gates and the normal build pass. No real provider calls or native fault, held-worker, or path-replacement scenarios were run.