fix: store 证伪时优先无状态 Responses,失败再降 Completions

This commit is contained in:
2026-09-25 00:29:51 +08:00
parent 71eca63461
commit 41f022bd63
3 changed files with 15 additions and 10 deletions
+1 -2
View File
@@ -376,8 +376,7 @@ apps/agent/
1. **Responses + `store=true`**(语义证实后;有会话链则只发增量 + `previous_response_id`)
2. store 未知:Responses + `store=true` + **Mongo 全量历史**,成功后再做语义探测
3. **store 证伪**(如 DeepSeek 返回 id 但不持久):**一律 Completions + Mongo 全量历史**
(LangChain 虽可把多轮打进 Responses `input`,但无状态兼容端常不可靠)
3. **store 证伪**:先 **无状态 Responses + Mongo 全量**,接口失败再 **Completions + Mongo 全量**
4. Responses 端点不可用 → Completions
成功后写入能力缓存。**`store=true` 认定**:独立语义探测——先让模型记住密钥,再仅用 `previous_response_id`(不带历史)追问;答对才记 true。未证实前禁止只发增量。
+4 -3
View File
@@ -34,8 +34,7 @@ def plan_protocol_attempts(
- store 已证实:Responses+store,有链则增量续聊
- store 未知:Responses+store + **Mongo 全量**,成功后再语义探测
- store 证伪:走 **Completions + Mongo 全量**
(DeepSeek 等无状态 Responses 会返回 id,但多轮 input 不可靠)
- store 证伪:先 **无状态 Responses + Mongo 全量**,失败再 **Completions**
- Responses 不可用:Completions
"""
style = normalize_api_style(api_style)
@@ -47,7 +46,9 @@ def plan_protocol_attempts(
attempts: list[ProtocolAttempt] = []
if cap.store is False:
# 无真实 store:一律 Completions + Mongo 全量(DeepSeek Responses 多轮不可靠)
# 无真实 store:无状态 Responses(全量历史)→ Completions
if cap.responses is not False:
attempts.append(ProtocolAttempt(True, False, False))
attempts.append(ProtocolAttempt(False, False, False))
return _dedupe(attempts)
+10 -5
View File
@@ -29,17 +29,22 @@ def test_plan_store_true_allows_chain():
assert ProtocolAttempt(True, True, False) in attempts
def test_plan_store_false_uses_completions():
"""DeepSeek 等:Responses 无状态时用 Completions 带 Mongo 历史。"""
def test_plan_store_false_prefers_stateless_responses_then_completions():
"""store 证伪:无状态 Responses(全量历史)→ Completions。"""
cap = LlmProtocolCapability(responses=True, store=False)
attempts = plan_protocol_attempts("auto", cap, has_chain_id=True)
assert attempts == [ProtocolAttempt(False, False, False)]
assert attempts == [
ProtocolAttempt(True, False, False),
ProtocolAttempt(False, False, False),
]
assert not any(a.use_chain or a.use_store for a in attempts)
def test_plan_store_false_forced_responses_still_completions():
def test_plan_store_false_forced_responses_same_ladder():
cap = LlmProtocolCapability(responses=True, store=False)
attempts = plan_protocol_attempts("responses", cap, has_chain_id=False)
assert attempts == [ProtocolAttempt(False, False, False)]
assert attempts[0] == ProtocolAttempt(True, False, False)
assert ProtocolAttempt(False, False, False) in attempts
def test_plan_completions_only():