openclaw - 💡(How to fix) Fix [Bug/Performance]: Agent prep latency regression — 25-30s overhead per turn on v2026.5.7 (Ollama takes only 2.3s) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#81548Fetched 2026-05-14 03:30:56
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
2
Timeline (top)
commented ×1

OpenClaw v2026.5.7 adds 25-30 seconds of overhead per agent turn that does not exist when calling Ollama directly with the same prompt size. This makes isolated agents unusable in production.

Root Cause

The issue appears identical to #75329 and #55762. The function resolvePromptBuildSystemPrompt() seems to be spending 25+ seconds building the system prompt from ~35KB of workspace files + tool definitions, even on continuation turns where contextInjection is set to continuation-skip.

The 2.3s Ollama result proves the model is NOT the bottleneck. The entire latency is inside OpenClaw's prompt assembly pipeline.

Code Example

# Direct Ollama (fast, 2.3s)
curl http://10.100.75.63:11434/api/generate \
  -d "{\"model\":\"gpt-oss:120b-cloud\",\"prompt\":\"<long context>...\nHola\",\"stream\":false}"

# Through OpenClaw (slow, 27.0s)
curl -H "Authorization: Bearer <password>" \
  -d "{\"model\":\"openclaw/cobuart\",\"messages\":[{\"role\":\"user\",\"content\":\"Hola\"}],\"max_tokens\":30,\"stream\":false}" \
  http://10.100.75.9:18789/v1/chat/completions
RAW_BUFFERClick to expand / collapse

Bug type

Performance regression

Summary

OpenClaw v2026.5.7 adds 25-30 seconds of overhead per agent turn that does not exist when calling Ollama directly with the same prompt size. This makes isolated agents unusable in production.

Environment

  • OpenClaw: 2026.5.7 (eeef486)
  • Ollama: remote at 10.100.75.63:11434
  • Model: gpt-oss:120b-cloud (also tested gemma4:31b-cloud, deepseek-v4-pro:cloud)
  • OS: Linux 6.12.74+deb13+1-amd64, Node v22.22.2
  • Agent: isolated agent "cobuart" with dedicated workspace (~10 workspace files, ~35KB total)

Measured Data

TestTimePrompt Tokens
Ollama direct (short prompt)1.0s~20
Ollama direct (~30K tokens / 120KB)2.3s24,523
OpenClaw → Cobuart Turn 127.0s29,524
OpenClaw → Cobuart Turn 230.1s44,380

Net OpenClaw overhead: ~25-28 seconds per turn.

Steps to Reproduce

  1. Create an isolated agent via openclaw agents add
  2. Send a trivial message (e.g., "Hola") via the chat completions endpoint
  3. Compare with direct Ollama call using the same prompt size
# Direct Ollama (fast, 2.3s)
curl http://10.100.75.63:11434/api/generate \
  -d "{\"model\":\"gpt-oss:120b-cloud\",\"prompt\":\"<long context>...\nHola\",\"stream\":false}"

# Through OpenClaw (slow, 27.0s)
curl -H "Authorization: Bearer <password>" \
  -d "{\"model\":\"openclaw/cobuart\",\"messages\":[{\"role\":\"user\",\"content\":\"Hola\"}],\"max_tokens\":30,\"stream\":false}" \
  http://10.100.75.9:18789/v1/chat/completions

What We Tried (no improvement)

  • contextInjection: "continuation-skip" — same latency (overhead is not from re-injection)
  • Reduced bootstrapMaxChars from 20000 to 8000
  • Reduced bootstrapTotalMaxChars from 150000 to 40000
  • Disabled bootstrap-extra-files hook
  • Multiple models: gemma4:31b-cloud, gpt-oss:120b-cloud, deepseek-v4-pro:cloud
  • thinking: off, reasoning: false

Analysis

The issue appears identical to #75329 and #55762. The function resolvePromptBuildSystemPrompt() seems to be spending 25+ seconds building the system prompt from ~35KB of workspace files + tool definitions, even on continuation turns where contextInjection is set to continuation-skip.

The 2.3s Ollama result proves the model is NOT the bottleneck. The entire latency is inside OpenClaw's prompt assembly pipeline.

Context Size Breakdown

  • Workspace files (AGENTS.md, SOUL.md, IDENTITY.md, USER.md, TOOLS.md, MEMORY.md, HEARTBEAT.md): ~10KB
  • Tool definitions (exec, read, write, edit, memory_search, etc.): ~8KB
  • Runtime prompt (OpenClaw system instructions): ~8KB
  • Skills list: ~3KB
  • Total: ~30KB → assembled into ~29K tokens of system prompt

Impact

  • Isolated agents are not viable for production with this latency
  • A user uploading a single CV takes 40+ seconds just for the agent to acknowledge
  • Multi-document workflows (typically 8-12 PDFs) would take 5+ minutes of wall-clock time
  • Open WebUI users see "typing..." for 30 seconds before any response

Expected Behavior

Agent prompt assembly should take <500ms for 30-50KB of text, similar to how Ollama processes the same content in 2.3s total including inference.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug/Performance]: Agent prep latency regression — 25-30s overhead per turn on v2026.5.7 (Ollama takes only 2.3s) [1 comments, 2 participants]