Repository navigation
improve: avoid reading sibling task history when starting a run - #156183
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 23, 2026, 2:16 AM ET / 06:16 UTC (Revision 3). ClawSweeper reviewWhat this changesTask creation stops loading unrelated runs from the same child session, with regression coverage for creation, reuse, and an absent run ID. Merge readiness✅ Ready for maintainer review Keep open: this remains a useful, narrowly scoped optimization absent from current main. No actionable correctness or security findings remain; the supplied evidence supports reduced initial-selection work, without establishing a whole-Gateway performance improvement. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s task registry records agent work in SQLite. Creation selects an existing matching run or creates a task, then a separate publication step refreshes the state used by the Gateway. flowchart TD
A[Task creation request] --> B[SQLite worker admission]
B --> C[Select task ID and matching run]
C --> D{Reusable task?}
D -->|Yes| E[Reuse or update task]
D -->|No| F[Create task]
E --> G[Broader publication readback]
F --> G
G --> H[Gateway task state]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +86. Total +86 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep creation selection bounded to eligible runs while preserving the existing canonical identifier, admission, and publication owners. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main selects and decodes sibling-session rows before rejecting unrelated run IDs; the supplied baseline measurements corroborate that path. This review did not execute target code. Is this the best way to solve the issue? Yes. Removing the redundant selector at the creation owner is a narrow solution that preserves reuse rules and broader publication discovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e857fba397ba. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash auto-merge.
|
* commit '3ab93b4ea59804b34d02a696382db16dc95189bb': (80 commits) fix(gateway): keep session refreshes moving during unrelated writes (openclaw#156286) chore(deps): update fs-safe to 0.18.2 (openclaw#156262) refactor(plugins): extract ClawHub plugin archives once (openclaw#156246) improve(llm-core): avoid unnecessary tool validation sets (openclaw#152066) fix(backup): verification accepts archives missing captured databases (openclaw#156211) fix: cancel Guest work when its original access is revoked (openclaw#156106) fix(test): classify drained legacy migration refusals fix(anthropic): finish Opus 5.5 defaults and thinking display (openclaw#156093) refactor(agents): share native harness tool execution (openclaw#154217) fix(ui): carry typed ownership through short-route resolution test(worktrees): accept additive gc result fields (openclaw#156127) test(tasks): close sqlite borrowers before registry reload (openclaw#156131) chore(autoreview): sync Astra high defaults (openclaw#156175) refactor(node-host): await prepared workspace storage (openclaw#149519) improve: speed up cold Node test planning (openclaw#156234) fix(doctor): avoid slow legacy ownership repair in source checkouts (openclaw#156238) improve: speed up native build artifact validation (openclaw#156219) fix(ui): preserve short-route resolution ownership fix(doctor): name retained session metadata conflicts (openclaw#156162) perf(tasks): bound creation selection to matching runs (openclaw#156183) ...
What Problem This Solves
Starting a task unnecessarily reads and decodes retained tasks from other runs in the same child session.
User Impact
Task creation does less work as a conversation's task history grows. Task identity, reuse, ordering, lifecycle, and delivery behavior stay the same; no new configuration or migration is required.
Why This Change Was Made
Creation only reuses an exact run match, so its initial database selection no longer includes unrelated runs sharing the child session. The canonical publication readback retains its broader scope and concurrency/discovery guarantees. This follows the existing canonical-ID contract: creation and explicit identifier changes normalize run IDs, while Doctor and legacy imports repair historical identifiers before activation.
Evidence
The new database-boundary regression covers creation, exact-run reuse, and an absent run ID. On the pinned baseline each case decodes 32 unrelated retained details; the candidate passes all three with zero unrelated decodes while preserving the selected and historical records. The file took 1.493 seconds of reported test time, 30.41 seconds standalone wall with
pnpm test src/tasks/task-registry-create.kernel.test.ts --maxWorkers=1. Hosted CI passed the same three cases in 32 ms of summed reported test time (12 / 10 / 10 ms), excluding shared setup, in the owning job.A paired Linux x64 / Node 24.19.0 benchmark exercised the actual creation kernel and SQLite in an isolated Node worker. Each unprofiled ABBA cell performed 100 creations, with setup and warmup excluded:
A separate counter run at 1,000 retained tasks observed 100,000 unrelated detail decodes (434,200,000 JSON bytes) before and zero after. Separate V8 allocation sampling, including collected objects, estimated 1,273,912,080 bytes before and 9,897,680 bytes after. Main-thread orchestration CPU was effectively unchanged (0.755 / 0.759 ms). These are initial-selection component measurements, excluding canonical publication/readback; they are not production-wide CPU savings.
Actual SQLite worker/Gateway dispatch integration exercised production write admission, creation receipts, publication, exact duplicate ordering, ACP backing reuse, and missing-origin second commits, with the agent provider mocked. It passed 50 of 51 local cases, including all 19 Gateway dispatch/terminal-lineage cases and all managed-link cases. The single existing
retries a changed page without joining events accepted after its first readcase timed out at its unchanged later-event barrier on a heavily loaded host; its fixtures use native creation and event/read paths rather than the changed worker selection. The original failure is retained; that same unchanged case passed on this exact head in hosted CI in 769 ms (owning job). An isolated Linux replay passed the original 29-test file group on the frozen baseline in 49.34 seconds. The candidate then passed all 116 creation, worker, Gateway, identifier, and Doctor sibling cases in 103.37 seconds. These passing replays do not establish a fixture fix. The remaining local task group did not start after that failure.Full changed-file checks passed, including core/test typechecks, formatting, lint, dead-code scans, and repository guards. Independent managed P0–P2 review found no actionable findings. Exact-head CI passed on
6b5ea98cc97815b0c00ea7fc9897dd336e906f64.The complete built-Gateway mock comparison used separate full baseline/candidate checkouts, Node 24.19.0, and four pinned CPUs. All eight ABBA cells verified six turns each (48 total), all 96 task-list probes succeeded, and every Gateway exited cleanly. Two-cell medians per variant were:
The empty-history control regressed, and neither cohort shows a main-thread CPU win. The 1,000-task cohort observed 6.5% lower process CPU with nearly unchanged wall time; this small comparison does not establish a uniform Gateway improvement or causal attribution of the differences. The 97.6% improvement applies only to the isolated initial-selection worker measurement above. Every macro cell had identical turn/probe counts and provider phase counts: six benchmark turns, six activity recaps, and one embedding request in the measured load.
The first two optional macro attempts ran zero measured turns: one seed helper omitted an environment-options argument; the next attempt was rejected by source verification because task-owned relocated build output remained in its checkout. The final proof used native
dist/layouts in isolated full checkouts. Original failures and all favorable/unfavorable results are retained.