feat(agents): tiered tool-calling system + KB coverage hint for smart routing

P0: Enrich Chapter 10 with detailed policy facts (QMAS scoring, GEP A/B/C
conditions, FAQ quick answers) so Claude can answer common questions directly
without tool calls. Replace absolute rule "never answer from memory" with
3-tier system: Tier 1 (direct from Ch10), Tier 2 (search_knowledge), Tier 3
(invoke_policy_expert).

P1: Context injector now always returns a kb_coverage_hint block — when KB has
results it tells Claude to prefer KB over web_search; when KB has no results
it suggests considering web_search. Web_search tool description updated to
reference the hint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-07 10:06:29 -08:00
parent b7e84ba3b6
commit 366a9cda3a
2 changed files with 123 additions and 53 deletions

View File

@ -290,13 +290,20 @@ export class ContextInjectorService {
const knowledge = await this.knowledgeClient.retrieveForPrompt({ const knowledge = await this.knowledgeClient.retrieveForPrompt({
query, userId: ctx.userId, query, userId: ctx.userId,
}); });
if (!knowledge) return null;
const content = [ let content: string;
`<relevant_knowledge>`, if (knowledge) {
knowledge.slice(0, 2000), // 限制长度 // KB has relevant content — inject knowledge + coverage hint
`</relevant_knowledge>`, content = [
].join('\n'); `<relevant_knowledge>`,
knowledge.slice(0, 2000),
`</relevant_knowledge>`,
`<kb_coverage_hint>知识库已覆盖该主题,优先基于以上知识回答。仅当知识库内容不足以回答时才考虑 web_search。</kb_coverage_hint>`,
].join('\n');
} else {
// KB has no relevant content — hint so Claude can decide on web_search
content = `<kb_coverage_hint>知识库中未找到与当前问题直接相关的内容。如问题涉及最新政策或知识库未收录的信息,可考虑 web_search。</kb_coverage_hint>`;
}
const block: ContextInjectionBlock = { const block: ContextInjectionBlock = {
contextType: ContextType.RELEVANT_KNOWLEDGE, contextType: ContextType.RELEVANT_KNOWLEDGE,

View File

@ -151,10 +151,22 @@ ${companyName} 是${companyDescription}。
- -
- -
**** ****
- **** invoke_policy_expert
- - **Tier 1 ******
- 使"觉得自己知道答案" - "高才通有几个类别?" A/B/C
- "优才需要雇主吗?"
- "大专能申优才吗?" 80
- **Tier 2 search_knowledge ** search_knowledge
- "XX大学在不在百强" search_knowledge
- "最新人才清单有哪些专业?" search_knowledge
- **Tier 3 invoke_policy_expert ******
- "优才综合计分制每一项详细评分标准" invoke_policy_expert
- "从递交申请到获批的完整流程是什么?" invoke_policy_expert
**** Tier 1 100% Tier 2
**** ****
- query - query
@ -343,6 +355,10 @@ ${companyName} 是${companyDescription}。
- -
- -
- -
- **使**
- \`<relevant_knowledge>\` 且包含了相关内容,说明知识库已覆盖该主题,**优先使用知识库内容**,不要调用 web_search
- \`<kb_coverage_hint>\` 提示知识库无相关内容,且问题确实涉及最新政策或外部信息,才考虑 web_search
- web_search
- ****web_search "根据最新公开信息" - ****web_search "根据最新公开信息"
### get_exchange_rate ### get_exchange_rate
@ -740,6 +756,7 @@ ${companyName} 是${companyDescription}。
- "好的""不是" - "好的""不是"
- -
- -
- **** 2.1 Tier 1 "确保准确" policy_expert
** Agent ** ** Agent **
- -
@ -1068,68 +1085,114 @@ ${categoriesList}
--- ---
# #
# # Tier 1
# #
使 ****Tier 1
invoke_policy_expert Tier 2 (search_knowledge) Tier 3 (invoke_policy_expert)
## 10.1 (QMAS) ## 10.1 (QMAS)
- ****Quality Migrant Admission Scheme ****
- **** - Quality Migrant Admission Scheme
- ****/ - ****
- **** 3+3+2 3+5 - 3+3+2
- **** - ****
- ****51
## 10.2 (GEP/TTPS - Top Talent Pass Scheme) ****
1. **** **80**
- 18-39(30), 40-44(20), 45-50(15), 51(0)
- /2(45), /2(30), (10)
- 10(50, 2++15), 5-9(40), 2-4(20)
- (20), +(15), (10)
- 20
- ****51 **30**
2. ****
- ****Top Talent Pass Scheme ****Tier 1
- **** - "大专能申优才吗?" (50)(30)(20)80线
- A类250 - "超过50岁能申请吗" 080
- B类 + 3 - "人才清单有哪些?" 51AI search_knowledge
- C类 + 310,000
- ****2 ## 10.2 (GEP / )
- ****4
- **** ****
- Top Talent Pass Scheme
- **2**
- **4**
****
| | | |
|------|------|------|
| A类 | **250**230 | |
| B类 | **** + **3** | |
| C类 | **** + 3 | **10,000/** |
**** QSTHEARWUUS News 5100
****
- "普通大学能走高才通吗?" B/C类必须百强大学A类不限学校250
- "应届毕业生能申请吗?" C类
- "XX大学在不在百强" search_knowledge
## 10.3 / (IANG) ## 10.3 / (IANG)
- ****Immigration Arrangements for Non-local Graduates - Immigration Arrangements for Non-local Graduates
- **** - **** **12**
- ****12
- **** - ****
- ****2+2+3 2+3+3 - 2+2+3 2+3+3
- **** - **** 广
- ****
## 10.4 / (TTPS/GEP) ****
- "IANG需要找到工作吗" 12
- "大陆分校毕业的算吗?"
- ****General Employment Policy / Admission Scheme for Mainland Talents and Professionals ## 10.4 / (GEP/TTPS)
- ****
- **** - (GEP)/
- ****2+3+3 - (TTPS)
- **** - ****
- **** -
- 2+3+3
- ****
****
- "没有雇主能申请吗?"
- "什么行业都可以吗?"
## 10.5 (CIES) ## 10.5 (CIES)
- ****Capital Investment Entrant Scheme - Capital Investment Entrant Scheme
- ****3,000 - **3,000**2,700
- **** - **7**
- **** - ****
- ****7 - ****
- **** -
- ****
****
- "可以买房移民吗?" /
- "3000万需要一直维持吗" 7
## 10.6 (TechTAS) ## 10.6 (TechTAS)
- ****Technology Talent Admission Scheme - Technology Talent Admission Scheme
- ****AI - AI
- **** - ****
- **** -
- ****
## 10.7
**** **7** "通常居住"
****
| | | | | |
|------|--------|---------|---------|---------|
| | | 80 | 6-12 | |
| | | 250 | ~4 | / |
| IANG | () | | 2-4 | |
| | | | 4-8 | offer |
| CIES | | 3000 | 6-9 | |
| TechTAS | () | | 2-4 | |
--- ---