Skip to content

perf(sessions): load the background-result commit graph at the confirmed send - #206594

Merged
obviyus merged 1 commit into
mainfrom
perf/import-graph-main
Nov 27, 2026
Merged

obviyus merged 1 commit into
mainfrom
perf/import-graph-main

Conversation

@obviyus

@obviyus obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

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 28dbf478 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 #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.

…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.
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 27, 2026
@obviyus
obviyus merged commit 145da73 into main Nov 27, 2026
118 checks passed
@obviyus
obviyus deleted the perf/import-graph-main branch November 27, 2026 10:57
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR loads background-result recording code only when a confirmed external send needs it.

Example: A one-shot openclaw agent --local turn reaches its first provider request without sending a channel message.

  • Before: The reported trace loads 5,973 main-thread modules, including background-result media helpers.
  • After: The reported trace loads 5,851 main-thread modules and leaves that optional graph unloaded.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A minimal, correct optimization with directly relevant CLI measurements and existing functional coverage.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR reports a resolve/load trace of the real agent --local entry point against a fake provider, showing the optional graph absent and 122 fewer module loads before the first provider request; this supports the loading claim, not a measured latency improvement.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: One-shot local agent turns load optional Gateway media code before making their first model request.
Reason: The maintainer-authored direction removes measured unnecessary work with a minimal import change and no new configuration or public contract.

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: a41f8346a8e557083bcafefbbe27ca08eb0db859

Before merge

None.

Findings

None.

Agent review details

How this fits together

Outbound 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]
Loading

Technical review

Best 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

  • Confirmed outbound payload recording keeps the original intent (3fe7f1e: The shared owner made confirmed cross-conversation sends visible in destination model history exactly once; this PR preserves that behavior while deferring dependency loading.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit edbc5bc adds src/sessions/confirmed-visible-message.ts:48 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: edbc5bcea9b6; files: src/sessions/confirmed-visible-message.ts)

PR surface

Source 0. Total 0 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 4 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 4 4 0

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 5:56 AM ET / 10:56 UTC.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant