Skip to content

memory-core: make context-service seam timeout configurable (800ms -> 2500ms default) - #4

Merged
pavel-satalkin merged 2 commits into
doctorina/base-v2026.6.6from
fred/context-service-timeout-env
Sep 9, 2026
Merged

pavel-satalkin merged 2 commits into
doctorina/base-v2026.6.6from
fred/context-service-timeout-env

Conversation

@fred-doctorina

Copy link
Copy Markdown
Collaborator

Why

The context-service search seam (__fredContextServiceSearch) is bounded by an abort timeout so a slow/cold context-service call can never stall a turn. That budget was hard-coded at 800ms.

Measured on the live deploy: a cold query-embedding round-trip through context-service takes ~700-760ms (OpenAI embedding warm-up + pg pool), while warm calls are ~150ms. At 800ms the first (cold) query per idle period is aborted and the seam silently falls through to the dead native memory path -> provider:none / backend:builtin / 0 hits. This is the root cause of intermittent "memory search returns nothing / index looks disabled" reports.

What

  • Extract resolveContextServiceTimeoutMs() and use it for the seam AbortSignal.timeout(...).
  • Default raised 800ms -> 2500ms (covers a cold call with margin).
  • Configurable via FRED_CONTEXT_SERVICE_TIMEOUT_MS; clamped to [100, 30000]ms; invalid/blank -> default.
  • Unit tests for default / parse / clamp / invalid.

Notes

  • No behavior change on success path other than the larger budget.
  • Base branch is doctorina/base-v2026.6.6 (the branch the gateway image is built from; main does not carry the seam).
  • Follow-up (separate, optional): boot-warm the embedding connection in services/context-service so even the first post-redeploy query is warm.

@pavel-satalkin
pavel-satalkin merged commit eac6cd4 into doctorina/base-v2026.6.6 Sep 9, 2026
1 check 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.

2 participants