Skip to content

fix(server): answer stdio clients while the stores are loading - #26

Merged
ipiton merged 2 commits into
mainfrom
bugfix/t175-stdio-startup
Nov 18, 2026
Merged

ipiton merged 2 commits into
mainfrom
bugfix/t175-stdio-startup

Conversation

@ipiton

@ipiton ipiton commented Nov 18, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Stops stdio clients from timing out while the server is still loading its stores.

  • The stdio server is built in the background, so initialize is answered immediately.
  • Other requests wait for readiness for at most 20 seconds from process start.
  • After that, tools/list returns the list derived from configuration, and other calls return a clear starting error.
  • Vector index startup steps are now logged.

This does not make startup faster. Under CPU starvation the first working search still takes minutes, and calls return starting until then.

Why?

Startup loads the memory cache and the vector index synchronously, and a stdio client had to wait for all of it on initialize. On a heavily loaded machine that wait exceeds client timeouts, so the client fails without a useful error.

Measurements used the real binary on a copy of a memory bank, with the process limited to 2% CPU and a 30-second client timeout:

initialize tools/list first working search
before, 2 runs timeout timeout; a retry answered after 163 s and 213 s 245 s; not reached within 280 s in the second run
after, 4 runs 2-8 s 20.1 s, 41 tools 372 s, with starting errors before it

The search numbers differ within run-to-run noise and show neither a speedup nor a slowdown.

Known follow-up: lazy loading of the memory cache is the actual fix for slow startup and needs a separate refactoring of internal/memory.

How to test

  1. make vet
  2. go test -race ./...
  3. Start the server over stdio on a copy of a bank with the process CPU-limited, then send initialize, tools/list and a search call.

Not verified: a cold filesystem cache, the original multi-minute scenario with heavy swap, and live Claude Code or Codex clients. CLI commands and hooks still load the same cache on every run; their timing was not measured. If a store fails to open after the 20-second window, tools stay listed but their calls fail. HTTP still answers 503 during startup.

Checklist

  • go test ./... passes
  • go vet ./... passes
  • Documentation updated (if behavior changed)
  • No hardcoded paths or API keys

@ipiton
ipiton merged commit 5761cbe into main Nov 18, 2026
5 checks passed
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