chore(sync): zsy_developcc 全量同步至 qyqy_develop(W26 口径)

- 分支内容对齐 qyqy_develop b6ec3aa,树完全一致(同步后 git diff 为空)
- 覆盖本轮全部交付:客服 Agent 重构(安全路由 / 五出口 / 记忆与画像 / RAG 全链路)
  + 开发文档 62 份编号体系(D1.1 v1.17 索引)
  + 新增 D2.10-客服Agent端到端答辩文档-2026-09-21.html
- 基线:e239eb7(2026-09-17 品牌口径统一快照),本提交为其直接后继
This commit is contained in:
张胜宇
2026-09-21 21:26:30 +08:00
parent e239eb778b
commit 9675df8453
330 changed files with 111939 additions and 8681 deletions
+51
View File
@@ -147,3 +147,54 @@ async def test_resolve_skips_endpoints_without_declared_capabilities(
agent_type="customer_service", task_type="chat"
)
assert [e.endpoint_code for e in resolved] == ["chat-primary"]
@pytest.mark.asyncio
async def test_resolve_warns_when_multiple_embedding_endpoints_declared(
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
) -> None:
"""声明 `embedding` 能力的 active 端点超过一个时必须告警(配置守卫,只告警不改行为)。
为什么要守:Milvus 集合的向量维度是固定的,索引侧与查询侧必须用**同一个**模型。
两个 embedding 端点共存时,`ModelDispatchService.embed` 只试前 `max(1, max_attempts)`
(默认 2)个端点,实际用哪个取决于表的行顺序 —— 一旦索引与查询落到不同模型,
`COSINE` 相似度整体失真却**不会报任何错**,表现为“越答越差”的哑故障。
"""
from app.service import model_gateway
rows = [
_endpoint("embedding-primary", ["embedding"]),
_endpoint("embedding-shadow", ["embedding"]),
_endpoint("chat-primary", ["chat"]),
]
monkeypatch.setattr(model_gateway, "SessionFactory", lambda: _FakeScalarSession(rows))
with caplog.at_level("WARNING"):
resolved = await model_gateway.DatabaseModelEndpointResolver().resolve(
agent_type="customer_service", task_type="embedding"
)
# 只告警不改行为:仍返回全部声明 embedding 的端点,且顺序与表行顺序一致。
assert [e.endpoint_code for e in resolved] == ["embedding-primary", "embedding-shadow"]
warnings = [r for r in caplog.records if r.levelname == "WARNING"]
assert warnings, "多 embedding 端点时必须留下 WARNING 痕迹"
assert "embedding-shadow" in warnings[-1].getMessage()
@pytest.mark.asyncio
async def test_resolve_is_silent_with_single_embedding_endpoint(
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
) -> None:
"""恰有一个 embedding 端点(现网配置)时不得产生告警噪音。"""
from app.service import model_gateway
rows = [_endpoint("embedding-primary", ["embedding"]), _endpoint("chat-primary", ["chat"])]
monkeypatch.setattr(model_gateway, "SessionFactory", lambda: _FakeScalarSession(rows))
with caplog.at_level("WARNING"):
resolved = await model_gateway.DatabaseModelEndpointResolver().resolve(
agent_type="customer_service", task_type="embedding"
)
assert [e.endpoint_code for e in resolved] == ["embedding-primary"]
assert [r for r in caplog.records if r.levelname == "WARNING"] == []