prep stages: totalMs=57374 stages=
workspace-sandbox:9ms@9ms,
skills:1ms@10ms,
core-plugin-tools:3602ms@3612ms,
bootstrap-context:5ms@3617ms,
bundle-tools:764ms@4381ms,
system-prompt:19242ms@23623ms, ← 19s on main thread
session-resource-loader:12290ms@35913ms,
agent-session:2ms@35915ms,
stream-setup:21459ms@57374ms
liveness warning: reasons=event_loop_delay,event_loop_utilization
interval=35s eventLoopDelayP99Ms=27363.6 eventLoopDelayMaxMs=27363.6
eventLoopUtilization=1 cpuCoreRatio=0.254 active=1 waiting=0 queued=0
[perf] system-prompt rebuild blocks event loop 16-29s per run; idle keeps 1 CPU core fully utilized
Environment
2026.4.29(npm:openclaw)secretary(gateway port 18790)embeddinggemma-300m-qat-Q8_0.gguf(sqlite-vec + FTS5 hybrid + MMR + temporalDecay)Symptoms
embedded-runprep stagestrace shows system-prompt = 16,527-29,185 ms as the single largest stage.liveness warningreportseventLoopUtilization=1, cpuCoreRatio≈1.06-1.08even whenactive=0 waiting=0 queued=0— main thread is fully saturated by background work.eventLoopDelayMaxMspeaks (27,363 ms,21,323 ms,14,621 ms) coincide with prep-stage rebuilds, causing client-visible timeouts (embedded run failover decision: stage=assistant decision=surface_error reason=timeout).bootstrapTotalMaxCharsfrom 150,000 → 60,000 helps but cannot eliminate, because the synchronous embedding search + MMR re-rank still runs on the main thread.Sample trace
Root-cause hypothesis
node-llama-cppembedding inference is invoked synchronously from the main event loop duringsystem-promptbuild.memorySearchhybrid (vector + FTS) + MMR re-rank + temporal-decay sort over 16K chunks runs in-process.Proposed mitigations (in order of impact)
node-llama-cppsupportsnThreads/ off-main inference).(workspaceState, memoryRevision, bootstrapBudget)hash so repeated runs reuse the rendered prompt.setImmediate/yieldEvery Nso it doesn't monopolize the loop.agents.defaults.memorySearch.workerThread = true.Workaround applied locally
bootstrapMaxChars20000 → 10000,bootstrapTotalMaxChars150000 → 60000.cpuCoreRatio≈1.07persists when idle.Repro
agents.defaults.contextInjection: "always"withbootstrapTotalMaxChars: 150000and a populated memory DB (>10K chunks).embedded-runand observe[trace:embedded-run] prep stagessystem-prompt≥15s.[diagnostic] liveness warningshowingeventLoopUtilization=1whileactive=0.