feat(recall): bilingual keyword search for cross-language recall - #302
Merged
jeff-r2026 merged 2 commits intoAug 20, 2026
Merged
Conversation
The knowledge base mixes Chinese and English, but recall is purely lexical (BM25 token matching) — a Chinese-only query never matches an English-only document, and vice versa. Instead of a hardcoded synonym dictionary, instruct the recall agent to expand each domain term into both languages when picking search keywords, leveraging the LLM's own translation. Proper nouns and identifiers (AppID, GPU, HAI) are kept as-is. Updates the teamai-recall subagent prompt (Step 2) and the built-in teamai-recall rule (Bash-command usage note) so both the subagent and direct `teamai recall` paths search bilingually. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the closed list of "proper nouns, acronyms, identifiers" with a general "language-neutral token" principle: keep as-is anything written the same way in both languages or with no meaningful translation — brand and product names, code identifiers and symbols, error codes, version strings, file paths, CLI commands, and API names. This covers boundary tokens the earlier enumeration missed (error codes, versions, paths, commands) instead of relying on a fixed set of examples. Also swap the business-specific product name in the examples for a neutral, widely-known one so the built-in prompt/rule stays generic across teams. Applied symmetrically to the teamai-recall subagent prompt and the built-in teamai-recall rule. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Team knowledge recall is purely lexical (BM25 token matching over a
shared
tokenize()on both the index and query sides). The knowledgebase mixes Chinese and English — a learning may be titled in English
while a task is described in Chinese, or vice versa. Because Chinese
query tokens and English document tokens are different strings, they
never match: a Chinese-only query cannot recall an English-only
document, and vice versa.
Approach
Rather than maintain a hardcoded synonym dictionary (zero coverage of
long-tail terms, ongoing maintenance burden), this leverages the LLM's
own translation ability at keyword-selection time. The recall agent is
instructed to expand every meaningful domain term into both
languages when building its search keywords, so a single query
carries tokens that can match documents in either language.
重启推理集群→restart inference cluster)restart inference cluster→重启 推理 集群)languages or with no meaningful translation (brand/product names,
code identifiers and symbols, error codes, version strings, file paths,
CLI commands, API names, e.g.
AppID,Kubernetes,GPU,RuntimeError,v2.1.3,oauth) — is kept as-is, since translating itonly hurts matching.
No code-path or index changes, no
SEARCH_INDEX_VERSIONbump, norebuild required — this is purely a prompt/rule refinement.
Changes
agents/teamai-recall.md— Step 2 (keyword extraction) now instructs bilingual expansion, keeping language-neutral tokens untranslated.src/builtin-rules.ts— the built-inteamai-recallrule's Bash-command usage note gets the same bilingual guidance, so the directteamai recallpath benefits too.Test Plan
npx tsc --noEmit— passes.teamai recallcommand expands domain terms bilingually while keeping language-neutral tokens intact:升级到 v2.1.3 后 nginx 报 502 Bad Gateway,如何排查→v2.1.3 nginx 502 Bad Gateway 排查 troubleshoot 升级 upgrade(version / brand / error code kept as-is)the oauth token refresh throws InvalidGrantError in production→oauth token refresh 刷新 InvalidGrantError production 生产环境(protocol / error code kept as-is)修改 src/utils/tokenizer.ts 的分词逻辑导致索引失效→src/utils/tokenizer.ts 分词 tokenizer 索引 index 失效 invalidation(file path kept as-is)为什么 kubectl apply 部署推理服务时 pod 一直 CrashLoopBackOff→kubectl apply 推理 inference 服务 service CrashLoopBackOff pod 部署 deploy(CLI command / pod state kept as-is)🤖 Generated with Claude Code