Skip to content

fix: raise answeragent-mcp timeout and batch vectorstore chunk lookup#1084

Merged
diecoscai merged 1 commit into
stagingfrom
fix/mcp-vectorstore-timeout
May 20, 2026
Merged

fix: raise answeragent-mcp timeout and batch vectorstore chunk lookup#1084
diecoscai merged 1 commit into
stagingfrom
fix/mcp-vectorstore-timeout

Conversation

@diecoscai
Copy link
Copy Markdown

Problem

The MCP query_vector_store / query_vector_store_with_filter tools (used by the Kumello agent) intermittently fail with MCP error -32603: timeout of 5000ms exceeded.

Two separate root causes:

  1. 5s client timeout with no margin. @answerai/answeragent-mcp's axios client defaults to timeout: 5000. The AnswerAgentMCP node spawns the MCP as a stdio subprocess, and MCP/core.ts spawns it with env: { ...serverParams.env, PATH } — the subprocess does not inherit process.env, so setting API_TIMEOUT on the service has no effect.
  2. A slow post-query loop. queryVectorStore reports only retriever.invoke() as timeTaken (~0.3–0.5s), but then runs one DocumentStoreFileChunk.findOneBy({ storeId, pageContent }) per result doc — N unindexed lookups on a text column. The full request takes 1–4s and the tail crosses 5s under load.

Changes

  • AnswerAgentMCP.ts — pass API_TIMEOUT into the subprocess env (default 30000, overridable via the ANSWERAGENT_MCP_API_TIMEOUT service env var). 30s is below the MCP SDK's 60s request timeout, so a genuinely slow call still fails cleanly.
  • documentstore/index.ts (queryVectorStore) — replace the per-doc lookup loop with a single batched In() query, guarded against an empty docs array (In([]) is undefined behavior in TypeORM). Behavior-equivalent; In was already imported.

Verification

  • pnpm --filter flowise-components build
  • pnpm --filter flowise build (server) ✅
  • Behavior-equivalent: doc.id / doc.chunkNo outcomes unchanged, including the else fallback branch.
  • doc.id / doc.chunkNo are consumed only by the Flowise UI "Test Query" view — the MCP/agent path never reads them, so the loop change cannot alter agent behavior.

Risk

Low and contained. Edit 1 only supplies a value to an already-supported knob and only affects the AnswerAgent MCP subprocess. Edit 2 only touches data used by an internal UI view, never the agent path.

Deploy

Requires a redeploy of the Kumello Flowise service after merge.

🤖 Generated with Claude Code

The MCP query_vector_store tool intermittently fails with 'timeout of 5000ms exceeded'. Two fixes:

- AnswerAgentMCP node: pass API_TIMEOUT to the answeragent-mcp subprocess (default 30s, overridable via ANSWERAGENT_MCP_API_TIMEOUT). The subprocess does not inherit process.env, so the axios client otherwise falls back to a hardcoded 5s timeout.

- queryVectorStore: replace the per-doc DocumentStoreFileChunk lookup loop (N unindexed pageContent queries) with a single batched In() query, guarded against empty results.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@diecoscai diecoscai self-assigned this May 20, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
answerai-docs Ready Ready Preview May 20, 2026 8:00pm
the-answerai Ready Ready Preview May 20, 2026 8:00pm

Request Review

@diecoscai diecoscai merged commit 09e1e9a into staging May 20, 2026
6 of 8 checks passed
@diecoscai diecoscai deleted the fix/mcp-vectorstore-timeout branch May 20, 2026 20:28
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