Repository navigation
improve(ollama): reduce inactive startup cost - #119745
Conversation
992d7cc to
6410dca
Compare
Punchcard-Session: coral-workshop-workshop-3f
6410dca to
7301506
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 7:30 PM ET / 23:30 UTC. ClawSweeper reviewWhat this changesThis PR moves optional Ollama setup, embedding, media, node-inference, streaming, and web-search implementations behind cached lazy runtime loaders to reduce default startup work. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open. The prior lazy-boundary finding is resolved on the exact head: registration now exposes lightweight contracts and defers optional Ollama runtimes until their owning operation. The PR remains a P1 performance repair for the broader cold-start regression and should await its exact-head checks before merge. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw loads bundled plugins during gateway startup; the Ollama plugin currently starts by importing provider, setup, stream, embedding, and optional tool implementations. This change keeps registration metadata and wrappers available immediately, then loads the relevant implementation on first use. flowchart LR
GatewayStartup[Gateway startup] --> PluginManifest[Bundled plugin activation]
PluginManifest --> Registration[Ollama registration]
Registration --> Contracts[Lightweight contracts]
Contracts --> FirstUse[Setup or provider operation]
FirstUse --> LazyLoad[Load owning runtime]
LazyLoad --> Result[Ollama capability result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +292, Tests +258, Other 0. Total +550 across 28 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the plugin-local lazy owner boundaries and merge only after exact-head packaging and behavior checks confirm the inactive startup path stays light while first-use operations retain behavior. Do we have a high-confidence way to reproduce the issue? Yes—source reproducible: the default-startup manifest and current entrypoint eagerly load optional Ollama runtime graphs before an operator uses Ollama. Is this the best way to solve the issue? Yes. Deferring imports inside the Ollama plugin preserves startup registration contracts; disabling the plugin by default or broadening core loader policy would be a worse owner boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d3d25737cf31. LabelsLabel changes:
Label 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)
|
|
Resolved every item from the prior ClawSweeper review on exact head
The stored-data detector remains a false positive: this PR changes no config, schema, migration, persistence, vector metadata, or embedding data model. All prior |
|
Maintainer resolution for exact head
Proceeding to repo-native prepare. Merge remains gated on current-main integration and the prepared exact head. |
|
Merged via squash.
|
* improve(ollama): defer optional runtime imports Punchcard-Session: coral-workshop-workshop-3f * improve(ollama): isolate lazy runtime modules * improve(ollama): preserve lazy runtime boundaries
…cope * origin/main: (24 commits) fix(backup): skip transient gateway lock databases (openclaw#119782) test(agents): use canonical auth session fixtures (openclaw#119821) fix(memory): keep QMD file hints after stale docid misses (issue openclaw#113041) (openclaw#113515) test(doctor): align fast-path repair contracts (openclaw#119812) perf(agents): index subagent recovery ownership (openclaw#119793) fix(gateway): keep chat startup off catalog discovery (openclaw#119742) fix(test): keep TUI PTY suites in their owner lane (openclaw#119787) docs: correct dashboard auth precedence (openclaw#119785) docs: document control ui owner handoff fix: grant host-authorized control ui owner access fix(worktrees): preserve registered roots during orphan cleanup (openclaw#119709) fix(matrix): prevent shared client key collisions (openclaw#119667) fix(diagnostics-otel): propagate exported span context (openclaw#112283) fix(worker): isolate state observer failures (openclaw#117507) fix(qa): attest realized profile executions (openclaw#119761) fix(gateway): finish successful sessions after timestamp races (openclaw#119752) fix(agents): fence restart recovery lifecycle (openclaw#119776) fix(ui): preserve chat history and active run timing (openclaw#119729) improve(ollama): reduce inactive startup cost (openclaw#119745) improve(gateway): defer inactive plugin runtime imports (openclaw#119733) ...
Related: #119087
What Problem This Solves
The bundled Ollama plugin loaded setup, embedding, media, node-inference, web-search, and native-stream runtimes during registration even when an operator did not use Ollama. That increased startup import time and memory for every process that registered bundled plugins.
Why This Change Was Made
This keeps lightweight registration contracts synchronous while loading each optional runtime once, on its first owning operation. Dynamically imported implementations now live in dedicated
*.runtime.tsmodules; the original public module names are lightweight contract facades.The native stream transport follows the existing lazy
StreamFnpattern. Compatibility payload policy stays synchronous, so wrapper behavior and ordering do not change.No config, default, persistence, protocol, or public API contract changes are introduced.
User Impact
Operators who do not use Ollama pay less startup time and memory. Operators who do use Ollama retain the same setup, discovery, embedding, media, node-inference, web-search, compatibility-wrapper, and native-stream behavior; the owning runtime loads on first use.
Exact-Head Evidence
55a9e7179c1bad965c5ac3342b22d2fb98657362.origin/main:d3d25737cf31547bd70ef9f0e1fcf2e3e7115f64; its newer Codex and Slack changes are path-disjoint, GitHub reports the PR mergeable, and repo-native prepare will integrate the final current main before merge.git diff --checkand exact-headoxfmt --checkpassed.sourcePerformancepackaged build passed in 9.36 seconds with zero ineffective-dynamic-import advisories.setup.runtime,embedding-provider.runtime,stream.runtime, andweb-search-provider.runtime; the startup registration entry imports none of those implementations eagerly.Performance Evidence
Measured implementation head:
992d7ccc841520c767ee9f1e30be562853b99c1e. The exact head preserves those lazy owner boundaries and adds the dedicated packaged runtime split above.7b8bba26c9539eb631a56ea65c2ff22771b2d0db, Node 24.15.0:Diff Shape
ClawSweeper Resolution
The prior exact-head review's two
Before mergeitems and both rank-up moves are implemented:stream.tsimplementation is now a verified rename tostream.runtime.ts, while public barrels use the explicit lazystream-api.tsfacade;The stored-data detector is a false positive: this PR changes no config, schema, migration, persistence, vector metadata, or embedding data model. It only changes when existing Ollama runtime code is imported.
Merge Gate
Merge only after clean exact-head CI and the latest exact-head ClawSweeper review has no unresolved
Before merge, finding, security, owner-decision, merge-risk, or blocking rank-up item.Punchcard-Session: coral-workshop-workshop-3f