You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: agent server loads all conversations eagerly at startup #3140
On startup, ConversationService.__aenter__ iterates every conversation directory on disk and calls _start_event_service for each one. Each call creates a LocalConversation (with agent, LLMs, event log), a lease-renew background task, and subscriber registrations. With 1000 persisted conversations, startup creates 1000 full conversation objects serially.
Location:conversation_service.py:742–785
Evidence
Code review of conversation_service.py:742–785. The startup loop is serial with no concurrency limit or lazy loading.
Severity: High
Impact of fix
Startup time drops from O(N) to O(1). Memory at startup is bounded regardless of how many conversations are persisted on disk.
Suggested fix
Load only conversation metadata at startup. Hydrate the full LocalConversation on first access (lazy loading). Consider LRU eviction for idle conversations.
Related issues and PRs
OpenHands#13193 — add auto_pause_existing flag and fix sandbox eviction order (open PR, eviction for sandboxes)
OpenHands#13892 — lazy-load models per provider (closed PR, similar lazy-loading pattern)
This issue is stale because it has been open for 40 days with no activity. Remove the stale label or leave a comment, otherwise it will be closed in 10 days.
👋 Also hitting this on Windows with npm run dev against openhands-agent-server v1.28.1. With ~89 conversations persisted under ~/.openhands/agent-canvas/conversations/, the agent-server spends ~12 s during startup walking them all before /server_info starts returning 200. The frontend blocks the whole UI on /server_info during that window, so the user-perceived "npm run dev takes a while" is dominated by this loop.
Quick log evidence (counts from a single boot):
89 × Resumed conversation <id> from persistent storage
133 × Added N secrets to conversation (distribution: 3×36, 4×86, 5×8, 1×3)
First successful GET /server_info lands ~40 s after npm run dev
One adjacent observation worth flagging while you implement lazy loading: the resume loop also silently re-injects the user's current saved secret set (/api/settings/secrets) into every dormant conversation, even ones the user has never reopened since the secret was saved. With lazy hydration that naturally falls out — secrets only need to be reattached when the conversation is actually opened — but it's a small behavior issue that piggybacks on this one.
Happy to test a PR when one lands.
(This comment was drafted by an AI agent (OpenHands) on behalf of the user, using their log evidence.)
Issue #4102 covers the same problem (lazy hydration of persisted conversations to avoid eager startup memory). Closing it as a duplicate and consolidating here.
Summary: Agent Server startup currently reconstructs every persisted conversation and its complete event history. Large historical corpora can consume gigabytes of idle memory before any conversation is used, causing watchdog failures and OOM termination. Persisted conversations should instead load into a lightweight catalog and hydrate exactly one runtime only when an operation needs it.
Current main evidence: With a reproducible persisted corpus containing at least 100 conversations and 50,000 event files, start and restart the real Agent Server on current main. Record exact commit, corpus size, startup logs, live-runtime count, and RSS after readiness; show that historical conversations and event histories are eagerly hydrated before any conversation is used.
PR branch evidence: Repeat the identical full-process startup/restart on the PR branch. Show search, count, and metadata reads returning the full catalog without runtime hydration; then use a real runtime/event operation to hydrate one conversation and verify that only it hydrates. Exercise simultaneous first access, running-conversation recovery, and a duplicate fork ID, proving one runtime is created and persisted metadata is not overwritten.
Required evidence package: Record both exact SHAs, OS/runtime versions, corpus generator and commands, readiness/restart logs, sanitized HTTP or service outputs, and comparable RSS samples. The live Agent Server process—not only direct unit calls—must demonstrate materially lower idle memory on the PR branch while preserving on-demand behavior.
Fixing PR
PR #4100 implements the lazy hydration approach described in this issue.
This comment was posted by an AI agent (OpenHands) on behalf of Graham Neubig.
Activity
github-actions commentedon Jun 22, 2026
This issue is stale because it has been open for 40 days with no activity. Remove the stale label or leave a comment, otherwise it will be closed in 10 days.
jamiechicago312 commentedon Jun 25, 2026
👋 Also hitting this on Windows with
npm run devagainst openhands-agent-server v1.28.1. With ~89 conversations persisted under~/.openhands/agent-canvas/conversations/, the agent-server spends ~12 s during startup walking them all before/server_infostarts returning 200. The frontend blocks the whole UI on/server_infoduring that window, so the user-perceived "npm run dev takes a while" is dominated by this loop.Quick log evidence (counts from a single boot):
Resumed conversation <id> from persistent storageAdded N secrets to conversation(distribution: 3×36, 4×86, 5×8, 1×3)GET /server_infolands ~40 s afternpm run devOne adjacent observation worth flagging while you implement lazy loading: the resume loop also silently re-injects the user's current saved secret set (
/api/settings/secrets) into every dormant conversation, even ones the user has never reopened since the secret was saved. With lazy hydration that naturally falls out — secrets only need to be reattached when the conversation is actually opened — but it's a small behavior issue that piggybacks on this one.Happy to test a PR when one lands.
(This comment was drafted by an AI agent (OpenHands) on behalf of the user, using their log evidence.)
neubig commentedon Jul 13, 2026
Duplicate issue #4102 merged here
Issue #4102 covers the same problem (lazy hydration of persisted conversations to avoid eager startup memory). Closing it as a duplicate and consolidating here.
Additional context from #4102
Summary: Agent Server startup currently reconstructs every persisted conversation and its complete event history. Large historical corpora can consume gigabytes of idle memory before any conversation is used, causing watchdog failures and OOM termination. Persisted conversations should instead load into a lightweight catalog and hydrate exactly one runtime only when an operation needs it.
PR evidence acceptance criteria (from #4102)
mainevidence: With a reproducible persisted corpus containing at least 100 conversations and 50,000 event files, start and restart the real Agent Server on current main. Record exact commit, corpus size, startup logs, live-runtime count, and RSS after readiness; show that historical conversations and event histories are eagerly hydrated before any conversation is used.Fixing PR
PR #4100 implements the lazy hydration approach described in this issue.
This comment was posted by an AI agent (OpenHands) on behalf of Graham Neubig.