You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(mcp): release-date queries exceed reranker batch limit (32) and silently skip the cross-encoder #308
For release_date intent queries, search_docs_auto fetches up to AUTO_TEMPORAL_CANDIDATE_DEPTH (default 50) hits, and reranker_client.rerank_hits() sends all the hits left after version matching to TEI /rerank in a single request.
TEI's default --max-client-batch-size is 32. docs-agent-mcp/terraform/variables.tf also sets 32, but docs-agent-mcp/terraform/reranker.tf uses $${var...} (double $), which Terraform treats as literal text, so the deployed value can't be confirmed from the repo. With a limit of 32, any request with more than 32 texts gets a 413. The broad except in reranker_client.py prints the error and returns the hits in raw BM25 order, so the only symptom is worse ranking.
Scope today (with a limit of 32):
Affected: any release_date query that still has more than 32 hits after version matching. This includes questions without a version (e.g. "When was Katib released?"), and versioned ones where no hit matches or more than 32 match.
Not affected by default: "latest" queries (skip the cross-encoder), comparison/exact queries (fetch 30), and general/conceptual queries (fetch top_k, max 20).
Expected behavior
Release-date candidates are reranked by the cross-encoder instead of silently falling back to BM25 order.
Rerank requests stay within the server's batch limit.
A fallback to unranked results is logged as a warning, not only printed.
Proposed fix: split rerank calls into chunks of at most RERANKER_MAX_BATCH (default 32, configurable) and merge the scores before sorting; replace the failure print with a logged warning; add unit tests for the >32 case and the fallback path. If reranking 50 texts is too slow in prod, an alternative is to rerank only the top 32.
Hi @fizae47-arch, thanks for your interest! I opened this one and asked to work on it in the description, so I'm picking it up.
I'd be glad to have your review on the PR once it's up.
@tarekabouzeid@Sharkyii I have a batching fix working locally with tests, and I'd like your input before I open the PR.
Reranking 50 texts took about 46s locally (TEI emulated on an M4 Mac, 2 CPUs), so it's not representative of prod. But RERANKER_TIMEOUT_SEC and the chart's remoteMcp.timeout are both 30s. Today these queries fail fast with a 413. With batching, a slow reranker could use the whole 30s, and the tool call could time out before the fallback returns.
What --max-client-batch-size does prod use? I can't confirm it from the repo (details in the description).
Roughly how long does reranking 30 texts take in prod?
If 50 is too slow, would you prefer (a) batching all candidates, or (b) fetching 50 but reranking only the top 32? I lean towards (a) if prod is fast enough, otherwise (b). Either way, the rerank budget probably needs to be below 30s.
I'd avoid lowering AUTO_TEMPORAL_CANDIDATE_DEPTH, since "latest" queries use it too. Raising TEI's limit wouldn't reduce the work.
I've also corrected the description (batch limit source, affected queries, and no truncation needed, since --auto-truncate is already set). I can open a separate issue for the $${var...} problem in reranker.tf.
Quick update: I have opened a draft PR for this in #311.
#290 added the reranker config (deploy/platform/reranker/inferenceservice.yaml), and it sets --max-client-batch-size to 32, so the 413 on release-date queries is confirmed.
The PR batches all candidates for now. @kmr-rohit, if reranking 50 texts turns out too slow in prod, I can switch it to rerank only the top 32. Let me know what you prefer.
Activity
fizae47-arch commentedon Nov 23, 2026
/assign
karan-panda commentedon Nov 24, 2026
Hi @fizae47-arch, thanks for your interest! I opened this one and asked to work on it in the description, so I'm picking it up.
I'd be glad to have your review on the PR once it's up.
/assign
karan-panda commentedon Nov 25, 2026
@tarekabouzeid @Sharkyii I have a batching fix working locally with tests, and I'd like your input before I open the PR.
Reranking 50 texts took about 46s locally (TEI emulated on an M4 Mac, 2 CPUs), so it's not representative of prod. But
RERANKER_TIMEOUT_SECand the chart'sremoteMcp.timeoutare both 30s. Today these queries fail fast with a 413. With batching, a slow reranker could use the whole 30s, and the tool call could time out before the fallback returns.--max-client-batch-sizedoes prod use? I can't confirm it from the repo (details in the description).I'd avoid lowering
AUTO_TEMPORAL_CANDIDATE_DEPTH, since "latest" queries use it too. Raising TEI's limit wouldn't reduce the work.I've also corrected the description (batch limit source, affected queries, and no truncation needed, since
--auto-truncateis already set). I can open a separate issue for the$${var...}problem inreranker.tf.karan-panda commentedon Dec 2, 2026
Quick update: I have opened a draft PR for this in #311.
#290 added the reranker config (deploy/platform/reranker/inferenceservice.yaml), and it sets --max-client-batch-size to 32, so the 413 on release-date queries is confirmed.
The PR batches all candidates for now. @kmr-rohit, if reranking 50 texts turns out too slow in prod, I can switch it to rerank only the top 32. Let me know what you prefer.