vmcp optimizer: OpenAI embeddings batch size hardcoded at 2048 — large MCP catalogs send whole-catalog embed requests
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 62/100
調査の方向性
pkg/vmcp/optimizer/internal/similarity/openai_client.go から始めてください。ここでは openAIMaxBatchSize が 2048 に固定されており、embed リクエストは 1 回の呼び出しで送信されています。入力が embeddings リクエストにどのように渡されるか、またバッチサイズがどこで使われているかを追ってください。embedding リクエストが、設定可能なサイズのチャンクに分割されていること(デフォルトは小さい値)と、大きな入力リストから複数のリクエストが生成されることをテストで示せば完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug description
pkg/vmcp/optimizer/internal/similarity/openai_client.go hardcodes openAIMaxBatchSize = 2048, so the session optimizer embeds an entire aggregated MCP catalog in a single /v1/embeddings request. Against a self-hosted OpenAI-compatible embedding backend, one request with hundreds of inputs can exhaust the server, and the optimizer failure then kills session creation on the gateway entirely — tools/list stops working for every client.
Steps to reproduce
- Run a gateway (
VirtualMCPServer) aggregating MCP servers whose combined catalog is large (ours: 10 servers → 521 tools, ~530 KB of tool name/description/schema text), withoptimizer.embeddingProvider: openaipointed at a self-hosted backend (litellm → OpenVINO Model Server,Qwen3-Embedding-0.6B-int8-ovon an Intel NPU). - Create a session against the gateway.
- The optimizer sends one embed request with 521 input strings.
Observed on the backend: 521 inputs in one request requires ~8.7 GB of transient host memory (per-input hidden states are accumulated before pooling), which exceeds what the box can give a single request; the request fails and the gateway logs failed to list core tools for session for every session (~every 5 min), so no session can be created at all.
Bisected against the backend: 64 inputs/request → OK; 128 inputs/request → fails. Empty input strings are handled fine; the failure is batch-size driven.
Expected behavior
Session creation succeeds. The optimizer should chunk its embedding requests to a size that self-hosted backends can serve, ideally configurable.
Actual behavior
Every session creation fails; the gateway is unusable for any client while the catalog is large, because the embed request is all-or-nothing (one 521-input request, no chunking below the 2048 cap).
Environment (if relevant)
- OS/version: Talos Linux 1.14.7, Kubernetes 1.34
- ToolHive version:
ghcr.io/stacklok/toolhive/vmcp:v0.69.0(deployed via toolhive-operator,VirtualMCPServerCRD withoptimizer.embeddingProvider: openai) - Backend: litellm → OVMS 2026.4.1, Qwen3-Embedding-0.6B-int8-ov, Intel NPU ( Panther Lake, UMA 64 GB)
Additional context
The OpenAI API's 2048-input cap is a hosted-API rate/abuse limit, not a good default for self-hosted backends where per-request input count drives server memory.
Request: make the optimizer's embed batch size configurable in OptimizerConfig / spec.optimizer (e.g. embeddingBatchSize, defaulting small — 32–64). Adaptive chunking on 4xx/5xx would also work, but an explicit knob is simpler and predictable.
- 主要言語
- Go
- スター
- 2.3k
- フォーク
- 335
- 平均マージ
- 18時間 4分
- マージ済み PR(30日)
- 194
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stacklok/toolhive のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
enhancement telemetry
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
stacklok/toolhive#6925 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
proxyrunner tool-filter middleware strips SEP-2322 Modern envelope from tools/list, breaking vMCP health checks再び着手できるかも @alex-feel が 60 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
stacklok/toolhive#6684 · コメント 5 件 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
HttpClientBuilder.Build() ignores HTTP(S)_PROXY (auth-server OAuth/DCR calls bypass forward proxy)対応中かも @schonmann が 51 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
stacklok/toolhive#6671 · コメント 2 件 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
stacklok/toolhive の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
nebari-dev/llm-serving-pack#270 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area/controller
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
volcano-sh/kthena#2109 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
unbound-force/replicator#193 ·
メンテナーはふだん 2 日以内に返信
-
A Gemini stream that fails partway completes the call with the partial text対応中かも @bnaylor が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
go-steer/core-agent#1600 ·
メンテナーはふだん 1 日以内に返信