Repository navigation
Description
Bug type
Crash (process/app exits or hangs)
Beta release blocker
No
Summary
Every chat turn through OpenClaw WebChat takes 30–90 seconds end-to-end on a 2 vCPU / 4 GB Docker VPS, while the same gpt-4o-mini call from inside the same container via curl returns in 0.83–1.73 seconds.
Steps to reproduce
- Deploy ghcr.io/openclaw/openclaw:2026.4.26 on Ubuntu 24.04 VPS (2 vCPU / 4 GB) via Docker Compose.
- Configure with OpenAI provider and gpt-4o-mini as primary model. Disable bonjour, browser, phone-control, talk-voice, acpx in plugins.entries. Leave openai and memory-core enabled.
- Open Control UI, wait for connection (chat.history and models.list complete in ~1.3s after Caddy WebSocket fix).
- Send the message: "What is 7+7?"
- Measure time from Send to full reply.
- From inside the same container, run curl directly to https://api.openai.com/v1/chat/completions with the same prompt and same model.
- Compare both timings.
Expected behavior
Direct OpenAI baseline from inside the same container, same model, same prompt:
Run 1: 1.73s HTTP:200
Run 2: 0.83s HTTP:200
Run 3: 0.87s HTTP:200
Median: ~0.87s
Expected: chat turn through OpenClaw should complete within a small multiple of the underlying model call (a few seconds of orchestration overhead is reasonable).
Actual behavior
Measured chat turns through OpenClaw WebChat (Control UI v2026.4.26):
"2+2" A=immediate, B=34s
"5+5" A=immediate, B=36s
"7+7" A=immediate, B>60s, sometimes never completes
"hi" A=immediate, B=36s
"who are you?" A=immediate, B=47s
Where A = time to first response chunk, B = time to full reply.
Recurring diagnostic in gateway logs during these turns:
[diagnostic] stuck session: sessionId=unknown sessionKey=agent:main:main state=processing age=216s queueDepth=1
During the wait, the gateway main process state via /proc:
state: S (sleeping)
wchan: ep_poll
syscall: 281 (epoll_pwait)
I/O counter delta over 5s: rchar=0, wchar=0, read_bytes=0, write_bytes=0
So the gateway is not CPU-bound, not disk-bound, not in a busy loop — it appears to be sleeping in epoll_wait while the chat turn is reported as "processing" with queueDepth=1.
OpenClaw version
2026.4.26
Operating system
Ubuntu 24.04.3 LTS, kernel 6.8.0-110-generic
Install method
docker (ghcr.io/openclaw/openclaw image via Docker Compose v5.1.3 / Docker 29.4.0)
Model
openai/gpt-4o-mini (also tested openai/gpt-4.1-mini — no measurable improvement)
Provider / routing chain
openclaw -> openai (direct, https://api.openai.com/v1) No proxies, no routers, no LiteLLM, no OpenRouter.
Additional provider/model setup details
Representative chat-turn log timeline:
00:10:49 webchat connected
00:10:51 commands.list ✓ 1054ms
00:10:52 device.pair.list ✓ 1753ms
00:10:52 node.list ✓ 1763ms
00:12:02 node.list ✓ 27161ms
00:13:33 chat.history ✓ 163489ms (before Caddy WS fix)
00:13:33 models.list ✓ 163478ms
00:15:36 [diagnostic] stuck session: sessionKey=agent:main:main state=processing age=216s queueDepth=1
After Caddy WebSocket transport tuning (read_timeout 1h, flush_interval -1):
chat.history: 163s -> 1.3s
models.list: 163s -> 1.3s
But agent-turn latency unchanged (still 30-90s).
Direct OpenAI baseline from inside container:
Run 1: 1.73s HTTP:200
Run 2: 0.83s HTTP:200
Run 3: 0.87s HTTP:200
Process state during a stuck turn (cat /proc//{wchan,status,syscall,stack,io}):
state: S (sleeping)
wchan: ep_poll
syscall 281 (epoll_pwait)
I/O counters over 5s: 0 byte delta on rchar/wchar/read_bytes/write_bytes
Open file descriptors during turn: runs.sqlite{,-wal,-shm}, gateway lock, eventfds, eventpolls. No suspicious activity.
Things attempted that did NOT resolve latency (only the first two affected behavior visibly):
- Disabled Bonjour via plugins.entries.bonjour.enabled=false (reduced startup noise, did not affect chat latency)
- Caddy WebSocket transport tuning (fixed UI bootstrap from 163s -> 1.3s, did not affect chat latency)
- Cleared plugin-runtime-deps cache (843MB -> 0, regenerated to 634MB on next start, no effect on chat latency)
- Blocked OpenRouter / LiteLLM via extra_hosts (pricing fetches fail in <50ms now, no effect on chat)
- Upgraded 2026.4.25 -> 2026.4.26 (fixed UI history-loss bug, did not fix chat latency)
- Tested via direct SSH tunnel bypassing Caddy entirely (same latency, so Caddy is not the cause)
- Disabled all bundled plugins except openai and memory-core
- Set mem_limit=1.5G, healthcheck start_period=200s
- Multiple full restarts and fresh state attempts
- Switched gpt-4o-mini -> gpt-4.1-mini (no measurable change)
- Workspace bootstrap files simplified (AGENTS.md 7850 -> 251 bytes, HEARTBEAT.md emptied) — no effect on latency, but agent lost personality (read BOOTSTRAP.md and ran first-run dialogue), so reverted.
Cold-start time: 130–150s consistently. Acceptable; not the issue.
Resource state during the issue:
Memory: 3.8 GiB total, 2.7 GiB available
Swap: 2.0 GiB total, ~100 MiB used
CPU idle: ~95%
Container memory: ~600 MB
Disk: 32% used of 77 GB
Logs, screenshots, and evidence
Impact and severity
Affected: Single-user self-hosted setup (personal AI assistant on small Docker VPS). Likely affects any small-VPS Docker deployment based on observed pattern.
Severity: High for interactive chat use case. System is technically functional (messages eventually arrive) but unusable as a real-time assistant given 30–90s per turn.
Frequency: Every single chat turn, including trivial single-token replies. 100% reproducible.
Consequence: OpenClaw cannot serve as an interactive chat companion in this configuration. Direct OpenAI usage and a co-hosted n8n agent on the same VPS both perform fast, so the VPS itself is not the bottleneck.
Additional information
Both 2026.4.25 and 2026.4.26 exhibit the same latency. 4.26 fixed the unrelated UI history-loss bug (chat history disappearing on reload — confirmed fixed).
Open questions for maintainers:
- What tracing or debug envs would help pinpoint where time is spent inside an agent turn?
- Is there a way to disable memory-core entirely on a fresh install? It's default-enabled and not in the usual config flow.
- Could OPENCLAW_DISABLE_PERSISTED_PLUGIN_REGISTRY=1 (mentioned in release notes as a deprecated break-glass) help here?
- Are there documented tunables for the agent runtime queue / session manager?
Happy to provide more logs, run tracing patches, or test fixes.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Apr 28, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.
Keep open. Current main has useful diagnostics and another narrow runtime-deps performance slice, but the latest issue discussion reproduces the latency on v2026.4.29 and points to several remaining pre-model stages rather than a fully fixed path.
Required change / next step:
Needs maintainer-guided affected-install retesting and profiling before a safe automated fix PR; current evidence is valid but not narrowed to one confirmed code hotspot on current main.
Security review:
Security review: No PR diff is under review, and this is an ordinary performance/latency issue rather than a security-sensitive report.
Review details
Best possible solution:
Keep this as the active Docker/WebChat agent-prep latency tracker, retest current main or the next package with trace-level embedded-run logs and /readyz event-loop diagnostics, then fix the single stage that dominates on the affected install.
Do we have a high-confidence way to reproduce the issue?
Yes for released builds: the original report gives concrete Docker/WebChat steps on v2026.4.26, and a later comment reproduces a similar Docker/VPS stall on v2026.4.29. Current main reproduction remains unconfirmed after the latest 3c48510 runtime-deps change.
Is this the best way to solve the issue?
No final solution is proven yet. The current patches are useful diagnostics and partial runtime-deps reductions, but the safest maintainable fix is a stage-specific change after current-main trace data shows whether model resolution, auth, tool construction, system-prompt work, or stream setup is still dominant.
Acceptance criteria:
What I checked:
src/gateway/server-methods/chat.ts:2059, 3c4851037b6c)src/agents/pi-embedded-runner/run.ts:471, 3c4851037b6c)src/agents/pi-embedded-runner/run/attempt.ts:775, 3c4851037b6c)src/plugins/bundled-runtime-deps.ts:387, 3c4851037b6c)Likely related people:
src/plugins/bundled-runtime-deps.ts,src/plugins/bundled-runtime-deps.test.ts,src/agents/pi-embedded-runner/run.ts)src/plugins/bundled-runtime-deps.test.ts,CHANGELOG.md)src/agents/pi-embedded-runner/run.ts)Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3c4851037b6c.
quangtran88 commentedon Apr 28, 2026
Adding fresh data on v2026.4.26 + answering @clawsweeper's ask for
transport: "sse"/openaiWsWarmup: falsetimings.Setup
ghcr.io/openclaw/openclaw:2026.4.26openaidirect (https://api.openai.com/v1), modelopenai/gpt-5.4Symptom Reproduced
So we see two distinct contributors:
embedded run starton the FIRST message per gateway process. Goes to 0.7s on the second message — pi-ai SDK/runtime is being lazily warmed.embedded run startandcreating streamFn wrapper, observed on EVERY message (including warm). Logs show 4×plugin tool factory returned null (oneclaw-multiagent): [telegram_*]immediately before the wrapper line, but the factory calls themselves are millisecond-cheap. The 11s is the cumulative cost of bootstrap context, MCP/LSP runtime creation, system-prompt assembly (14,369 chars in our case), and provider config — acrossattempt.tslines 583–1551 (research/openclaw/repo/src/agents/pi-embedded-runner/run/attempt.ts).On the
transport: "sse"/openaiWsWarmup: falseaskWe tried the documented overrides per
docs/concepts/model-providers.md:88:and the simpler global form:
Both get stripped from
openclaw.jsonon disk ~13s after gateway start. We verified:generate-config.mjswrites the field (confirmed vianode /app/generate-config.mjs /tmp/test.jsoninside the container — field present)openclaw.jsonmtime advances 13s after container start — gateway is rewriting itagents.defaults.paramsnoragents.defaults.models["openai/gpt-5.4"].paramssrc/config/zod-schema.agent-defaults.ts:43) accepts both shapes via.strict()withparams: z.record(z.string(), z.unknown())applyModelAliasDefaults(src/config/defaults.ts:255) appears to preserveparamsin-memorySo the override path documented in
model-providers.md:88is non-functional in v2026.4.26 — the runtime persist/reload cycle drops the field beforeextra-params.tsreads it. From our logs,creating streamFn wrapper with params: {"transport":"auto","openaiWsWarmup":false}confirmstransport=autois what reaches the wrapper, regardless of what we put in the file.We did NOT find an env-var override (
OPENCLAW_*TRANSPORT*doesn't exist in the agents/ tree), so we couldn't validate the SSE-only path on this image without patching upstream.What's working in v2026.4.26 on our side
agent:bootstrapregisterHook withnameoption ✓channelConfigsfor 5 channels ✓allowConversationAccessfor typed conversation hooks (multiagent agent_end, phoenix llm_input/llm_output) ✓Eager init noise (orthogonal — not new)
Boot logs show:
Race in our plugin's
getPluginRuntime()deref before SDK store hydrates. Pre-existing on our side, retry succeeds, not introduced by v26 — flagging only because it appears in the same boot window.Asks
agents.defaults.params/agents.defaults.models[].paramsstrip a known regression in v26's persist/reload, or is the documented override path expected to use a different shape?--flagoverride fortransport/openaiWsWarmupwe missed?I can post finer-grained
attempt.tstimestamps from a debug-logging build if it would help isolate which sub-step in 583–1551 dominates the 11s.Heyvhuang commentedon Apr 28, 2026
I can reproduce the high pre-run latency on
v2026.4.26, but I do not see the same issue on thev2026.4.14line.The important difference is that
v2026.4.14still has tools available and callable in my test environment. This does not look like a “no tools enabled” comparison.On
v2026.4.26, the main delay does not appear to be the model call itself. In repeated short-message tests, the slow section is consistently beforerun_started.Approximate breakdown:
steipete commentedon Apr 29, 2026
Landed a narrow runtime-deps latency slice on main: 234cbf5 (
perf(plugins): memoize packaged runtime dist mirrors).What changed:
src/plugins/bundled-runtime-dist-mirror-cache.tsadds a per-process memo for packaged bundled dist-mirror preparation.src/plugins/loader.tsandsrc/plugins/bundled-runtime-root.tsnow skip repeat rootdist/mirror scans once a packaged mirror has been prepared, while still refreshing plugin roots and leaving source-checkout mirrors uncached.src/plugins/bundled-runtime-root.test.tscovers the packaged cache and source-checkout escape hatch.Validation:
pnpm test src/plugins/bundled-runtime-root.test.ts src/plugins/bundled-runtime-deps.test.tspassed, 99 tests.pnpm test src/plugins/loader.test.ts -- -t "materializes root JavaScript chunks in external runtime mirrors"passed.oxfmt --checkandgit diff --checkpassed.tbx_01kqcj2cgth1b3219amqadnmjk:OPENCLAW_TESTBOX=1 pnpm check:changedpassed across core/coreTests/docs lanes.Not closing this yet. This removes another repeated pre-turn packaged-loader scan that matches the event-loop-starvation cluster, but affected Docker/VPS installs should retest current main or the next package before we call #73428 fully fixed.
steipete commentedon Apr 29, 2026
Landed another narrow diagnostic slice on main: 20e2117 (
fix(agents): trace slow embedded run startup stages).What changed:
runEmbeddedPiAgentnow emits an embedded-run startup stage summary before dispatching the attempt, covering workspace resolution, runtime plugin loading, hooks, model resolution, auth, context engine setup, and attempt dispatch.runEmbeddedAttemptnow emits a prep-stage summary before model I/O / stream wrapping, covering workspace+sandbox, skills, core/plugin tools, bootstrap context, bundled MCP/LSP tools, system prompt build, session/resource loader, agent session creation, and stream setup.Validation:
pnpm test src/agents/pi-embedded-runner/run/attempt-stage-timing.test.tsoxfmt --checkandgit diff --check20e21173:OPENCLAW_TESTBOX=1 pnpm check:changed --base HEAD~1 --head HEADselectedcore, coreTests, docsand passed.Keeping this open. This does not claim the full Docker/VPS latency regression is fixed yet; it should make the next v2026.4.27+ repro identify whether the remaining pre-model time is in plugin loading, auth/model resolution, tool inventory, bootstrap, bundled MCP/LSP, resource loading, or stream setup.
steipete commentedon Apr 29, 2026
Follow-up on the diagnostic logging behavior: main now includes 66cdbcc (
fix(agents): demote embedded run stage logs to trace) plus 03e17d1 (test(plugins): avoid map spread in provider fixture).The stage summaries are now
[trace:embedded-run]trace-level lines for normal support captures. They only promote towarnfor severe cases: total startup/prep >=10s or a single stage >=5s. That keeps normal gateway logs quiet while still making the #73428 repro path easy to grep whenOPENCLAW_LOG_LEVEL=traceis enabled.Validation on Blacksmith Testbox for
03e17d19:OPENCLAW_TESTBOX=1 pnpm check:changed --base HEAD~2 --head HEADselectedcore, coreTests, docsand passed.crash2kx commentedon Apr 30, 2026
I can reproduce a very similar issue on a separate Docker/VPS install after updating to
2026.4.29.This no longer looks Telegram-specific. It reproduces both from Telegram and from Control UI/WebChat:
2026.4.29/healthztimes out during the spike, then returns HTTP 200 afterwardRepresentative timings from the updated install:
A Control UI/WebChat run showed almost the same shape:
The trajectory for the same Control UI run showed the model itself was not slow:
So
2026.4.29appears to have improved/fixed the earlier repeated filesystem/plugin materialization issue reported in #74240, but a separate per-turn agent-prep/main-thread blocking problem remains. The most suspicious repeated stages arecore-plugin-tools,model-resolution,auth, andstream-setup.Happy to run a specific trace or debug flag if maintainers can point to the best instrumentation.
Heyvhuang commentedon May 1, 2026
Adding one more data point: I agree with the observation above that this does not look Telegram-specific.
I tested a separate Docker/VPS-hosted instance with
2026.4.29-slim, and the same regression reproduces from Control UI/WebChat as well. So the delay appears to be inside the Gateway / agent preparation path, not in the Telegram transport.Environment:
2026.4.29-slimghcr.io/openclaw/openclaw:2026.4.29-slimRepresentative WebChat timeline:
During the same window, the gateway emitted:
The agent turn trace showed the delay before streaming/model output:
After the spike, the gateway recovered and later websocket calls were fast again:
So this looks like the same per-turn Gateway / agent-prep main-thread blocking issue described above. The most suspicious repeated stages from my run are
core-plugin-tools,auth,system-prompt,stream-setup, andmodels.list.Happy to test a patched image or run any debug flag that would help narrow this down.
timxx commentedon May 1, 2026
I have the same problem on Arch Linux (not VPS), even with a refresh install, the chat response is delay too much:
steipete commentedon May 1, 2026
Rechecked against current
origin/main(666ab0a00b). Keeping this open.What is fixed or improved on main:
29ed5266bf(fix: keep runtime deps repair out of hot paths), plus provider/runtime hook caching (354084b1b3) and related plugin-runtime reductions.b68f3de91b(fix(agent): honor explicit OpenAI SSE transport).tools.effective, but closed because it mostly moved work around rather than materially fixing this issue.Why this is not closeable yet:
core-plugin-tools,auth,model-resolution,system-prompt,stream-setup), not one fully fixed runtime-deps cache bug.core-plugin-tools, and Agent prep takes >40s: system-prompt building regression (30-35s spent in resolvePromptBuildSystemPrompt) #75329 forsystem-promptcost.So #73428 should stay as the umbrella Docker/WebChat latency tracker until a current-main/package retest shows the full 30-90s pre-model delay is gone. The next useful proof is another affected install on a build containing
666ab0a00bor newer with[trace:embedded-run]startup/prep stage lines.steipete commentedon May 1, 2026
Closing this out now: current
maincontains multiple latency/runtime hot-path fixes since the original report, and the remaining reports have been split into narrower follow-ups (#75616, #75290, #75329).If this exact Docker/WebChat 30-90s latency still reproduces on a build containing current
mainor the next package with the stage traces enabled, please reopen with the fresh[trace:embedded-run]startup/prep lines so we can chase the remaining bucket directly.