Skip to content

fix(web): warm lancedb at startup to fix first-run MCP bootstrap_failure#33

Open
jeanbrazeau wants to merge 1 commit into
solatis:masterfrom
jeanbrazeau:fix/cold-start-mcp-bootstrap-race
Open

fix(web): warm lancedb at startup to fix first-run MCP bootstrap_failure#33
jeanbrazeau wants to merge 1 commit into
solatis:masterfrom
jeanbrazeau:fix/cold-start-mcp-bootstrap-race

Conversation

@jeanbrazeau

Copy link
Copy Markdown

On a cold server the first lazy import lancedb (koan/memory/retrieval/index.py) runs synchronously on the asyncio event loop during the first run. The seconds-long native import blocks the loop in the exact window where a freshly-spawned agent's CLI fetches tools/list from koan's MCP server. The response never arrives, so the agent starts with no koan tools, never calls koan_complete_step, and the run dies with bootstrap_failure ("Process exited before first koan_complete_step call"). Subsequent runs were fine because lancedb was already warm.

Warm koan.memory.retrieval.index in the server lifespan, off-loop via asyncio.to_thread, before the server accepts any run. Best-effort: a warmup failure is logged at debug and never blocks startup.

On a cold server the first lazy `import lancedb` (koan/memory/retrieval/index.py)
runs synchronously on the asyncio event loop during the first run. The
seconds-long native import blocks the loop in the exact window where a
freshly-spawned agent's CLI fetches tools/list from koan's MCP server. The
response never arrives, so the agent starts with no koan tools, never calls
koan_complete_step, and the run dies with bootstrap_failure ("Process exited
before first koan_complete_step call"). Subsequent runs were fine because
lancedb was already warm.

Warm koan.memory.retrieval.index in the server lifespan, off-loop via
asyncio.to_thread, before the server accepts any run. Best-effort: a warmup
failure is logged at debug and never blocks startup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant