Business Context Injection
Business Context Injection 是将业务上下文(产品信息、政策规则、业务状态)注入到 LLM 上下文的技术,让 Agent 能够基于业务知识回答问题。
#type / concept
#status / evergreen
#tech / ai
[!info] related notes
- 所属 MOC: Context Engineering MOC
- 相关: Retrieval Context, Prompt Assembly
Business Context Injection
一句话定义
Business Context Injection 是将业务上下文注入到 LLM 上下文的技术。当用户问”退款政策是什么”时,Agent 需要把当前的退款政策注入上下文,而不是让 LLM 猜。
核心原理
业务上下文类型
| 类型 | 例子 | 注入方式 |
|---|---|---|
| 产品信息 | 产品手册、FAQ | RAG 检索 |
| 政策规则 | 退款政策、隐私政策 | 固定注入 |
| 业务状态 | 当前库存、价格 | API 获取后注入 |
| 组织信息 | 公司介绍、团队信息 | 固定注入 |
注入方式
def build_business_context(context_type: str, query: str) -> str:
if context_type == "policy":
# 政策规则固定注入
return get_policy_context()
elif context_type == "product":
# 产品信息 RAG 检索
return rag_engine.retrieve(query)
elif context_type == "status":
# 业务状态 API 获取
return get_business_status()
常见坑
- 不注入业务上下文: LLM 用自己的知识回答,可能过时
- 注入太多: 所有政策都注入,浪费 token
- 不更新: 政策变了但注入的内容没变