Repository navigation
perf(sessions): load the background-result commit graph at the confirmed send - #206594
Conversation
…med send - confirmed-visible-message imported background-result-payloads (gateway chat media helpers) statically through the outbound delivery modules every agent turn loads. - Main thread loads 122 fewer modules before the first provider request of a one-shot agent --local turn.
|
🦞👀 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: passed. What this changesThis PR loads background-result recording code only when a confirmed external send needs it. Example: A one-shot
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR makes a focused, measured startup improvement without introducing a correctness or security defect. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherOutbound delivery passes confirmed payloads and destination context to the shared session-history owner, which records eligible messages through the background-result writer. flowchart TD
A[Local agent turn] --> B[Outbound delivery modules]
B --> C[Confirmed visible message owner]
C --> D[Resolve eligible destination]
D --> E[Load background payload writer]
E --> F[Commit destination history]
Technical reviewBest possible solution: Keep the lazy import at the existing confirmed-send owner and retain its recording contract. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the eager dependency, and the author supplies before/after module-load measurements through the shipped CLI; this review ran no target code. Is this the best way to solve the issue? Deferring the sole runtime use is the smallest complete change: it removes unnecessary startup work while preserving the existing writer, guards, payload arguments, and deduplication identity. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 937f6ede16e9. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0. Total 0 across 1 file. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 27, 2026, 5:56 AM ET / 10:56 UTC. |
…med send (openclaw#206594) ## Problem `src/sessions/confirmed-visible-message.ts` statically imports `commitBackgroundPayloadsToSession` from `sessions/background-result-payloads.ts`, which pulls in gateway chat media helpers (`gateway/server-methods/chat-reply-media` and its graph). `confirmed-visible-message` sits under the outbound delivery modules (`deliver-core`, `delivery-queue-transcript`, `outbound-send-service`) that `agent-command` imports. So every one-shot `openclaw agent --local` turn loads that graph before its first model request, although the commit runs only after a channel confirms an external send. ## Change Load `background-result-payloads.js` at the one place it is used, after the destination entry is read and right before the commit. The type import stays static. No behavior change: the same function runs with the same arguments inside the same `runWithoutOwnedSessionTranscriptWrites` scope. ## Evidence Main-thread import graph before the first provider request, one fake-provider `agent --local` turn on main `bb97b857` with a resolve/load trace (cut at the first `POST /v1/responses`), dominator tree from the entry: | | base | this PR | |---|---:|---:| | `background-result-payloads` dominated modules (loaded only through it) | 124 (823 KB) | not loaded | | main-thread modules before the request | 5,973 (39.4 MB) | 5,851 (38.5 MB) | | all-thread module loads before the request | 14,770 | 14,648 | Head counts are identical in 2 runs. The openclaw#206466 gate counts processes and workers; neither changes, so its budget is unchanged. Tests: the 8 test files that import `confirmed-visible-message` or `background-result-payloads` pass locally; format and type-aware oxlint clean. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
src/sessions/confirmed-visible-message.tsstatically importscommitBackgroundPayloadsToSessionfromsessions/background-result-payloads.ts, which pulls in gateway chat media helpers (gateway/server-methods/chat-reply-mediaand its graph).confirmed-visible-messagesits under the outbound delivery modules (deliver-core,delivery-queue-transcript,outbound-send-service) thatagent-commandimports. So every one-shotopenclaw agent --localturn loads that graph before its first model request, although the commit runs only after a channel confirms an external send.Change
Load
background-result-payloads.jsat the one place it is used, after the destination entry is read and right before the commit. The type import stays static. No behavior change: the same function runs with the same arguments inside the samerunWithoutOwnedSessionTranscriptWritesscope.Evidence
Main-thread import graph before the first provider request, one fake-provider
agent --localturn on main28dbf478with a resolve/load trace (cut at the firstPOST /v1/responses), dominator tree from the entry:background-result-payloadsdominated modules (loaded only through it)Head counts are identical in 2 runs. The #206466 gate counts processes and workers; neither changes, so its budget is unchanged.
Tests: the 8 test files that import
confirmed-visible-messageorbackground-result-payloadspass locally; format and type-aware oxlint clean.