Merge branch 'dev' into hugo-shipping-notice

This commit is contained in:
hugo committed 2026-08-11 14:33:56 +08:00
commit 472b530be3
397 files changed
+46450 -34171

No files matched your search

@@ -192,6 +192,51 @@ def test_local_assistant_message_query_does_not_duplicate_user_bubble(client):
assert msgs[-1]['content'] == '已确认,进入下一步。'
def test_local_typed_assistant_message_keeps_query_for_user_bubble_and_title(client):
"""结构化结果卡须保留 query:刷新后回放用户提问,会话标题用提问而非 headline。"""
headers = get_headers(client)
user_question = '请对《邦达激光合同.pdf》进行模板比对'
headline = '模板比对完成:高 1 / 中 0 / 低 0,共 1 处变更'
save_res = client.post('/api/chat/messages/local?agent_id=1', headers=headers, json={
'conversation_id': 'conv-contract-review',
'role': 'assistant',
'type': 'procurement-contract-review',
'content': headline,
'query': user_question,
'payload': {
'review_no': 'CR-TEST-001',
'contract_file_name': '邦达激光合同.pdf',
'high_risk_count': 1,
'medium_risk_count': 0,
'low_risk_count': 0,
},
})
assert save_res.status_code == 200
# 断言:历史回放含用户气泡 + 结果卡
msg_res = client.get(
'/api/chat/messages?conversation_id=conv-contract-review&agent_id=1',
headers=headers,
)
assert msg_res.status_code == 200
msgs = msg_res.get_json()
assert len(msgs) >= 2
assert msgs[0]['role'] == 'user'
assert msgs[0]['content'] == user_question
assert msgs[-1]['role'] == 'assistant'
assert msgs[-1]['type'] == 'procurement-contract-review'
# 断言:侧栏标题取用户提问,而非审查 headline
sessions_res = client.get('/api/chat/sessions?agent_id=1', headers=headers)
assert sessions_res.status_code == 200
sessions = sessions_res.get_json()
target = next((s for s in sessions if s['conversation_id'] == 'conv-contract-review'), None)
assert target is not None
assert target['title'].startswith('请对《邦达激光合同.pdf》')
assert '模板比对完成' not in target['title']
def test_chat_sessions_keep_latest_non_empty_query_as_title(client):
headers = get_headers(client)