Skip to content

Performance: avoid reloading embedding model on every query in docs-agent API #63

Closed as not planned

Description

@alokdangre

Summary

server-https/app.py (and server/app.py) instantiate SentenceTransformer inside milvus_search() for every tool call. This causes avoidable latency and memory churn.

Problem

Current behavior:

  • Each request that triggers search_kubeflow_docs re-creates the embedding model.
  • Model load time dominates query latency under repeated traffic.

Expected behavior:

  • Embedding model should be initialized once per process and reused across queries. for low latency

Activity

  1. added 4 commits that reference this issue on Feb 28, 2026
    70f523a
    9148732
    320aaf7
    496aebe
  2. JayDS22 commented on Mar 27, 2026

    @JayDS22

    Nice find. The MCP server in kagent-feast-mcp/mcp-server/server.py already handles this with a lazy _init() pattern where the model and client are globals that only initialize once.

    Worth noting this isn't the only per-request cost. The main servers also do connections.connect() + disconnect() on every call ([#28]) and run collection.load() each time. So each search is paying three initialization penalties. The MCP server sidesteps all of them because MilvusClient handles connection and collection state internally.

    Somewhat related: even after the search runs, the servers truncate content_text to 400 chars before the LLM sees it, even though the pipeline stored 2000 chars. Filed that separately as [#181]

  3. chasecadet commented on Nov 20, 2026

    @chasecadet
    Contributor

    Thank you for reporting this!

    We are closing pre-restructure issues targeting the legacy server/, server-https/, manifests/, kagent-feast-mcp/, or in-process SentenceTransformer prototype code. In #207, #210, #233, #240, and #249, kubeflow/docs-agent migrated to dedicated TEI (text-embeddings-inference), FastMCP (docs-agent-mcp/mcp-server/), shared modular KFP pipelines (docs-agent-mcp/pipelines/), and Helm charts (docs-agent-mcp/charts/).

    If you still observe an equivalent issue on the current main stack, please feel free to open a new issue using the current issue templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions