feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:18:37 +08:00
1 parent 3a9fbac2fc
commit d2b3d74def
571 files changed
+78064 -24681

No files matched your search

+21 -17
View File
@@ -3,7 +3,8 @@ tests/test_chat_dify_start_inputs.py
用途:迭代 5 验收 — Executor / completions 向 Dify Start 注入 agent_runtime_context。
依赖:agent_runtime_context.bootstrap、chat.executors、models、pytest。
逻辑:覆盖 generic / shipping_notice / file_check 三类 Agent 的 Dify inputs 契约。
逻辑:覆盖 generic / shipping_notice / file_check 三类 Agent 的 Dify inputs 契约;
co8 后 shipping 用例仅挂 ShippingNotice(无 ShippingBatch)。
"""
from __future__ import annotations
@@ -11,14 +12,13 @@ from __future__ import annotations
import json
from types import SimpleNamespace
import pytest
from app.models import ShippingBatch, ShippingTask, User
from app.models import ShippingNotice, User
from app.services.agent_registry.handlers.base import ChatStreamContext
from app.services.agent_runtime_context import AGENT_RUNTIME_CONTEXT_INPUT
from app.services.agent_runtime_context.bootstrap import load_context_adapters
from app.services.agent_runtime_context.registry import build_chat_dify_inputs
from app.services.chat.executors import stream_chat_via_executor
import pytest
@pytest.fixture(autouse=True)
@@ -77,7 +77,11 @@ def test_dify_executor_injects_generic_agent_runtime_context(app, monkeypatch):
def test_hybrid_executor_injects_shipping_agent_runtime_context(app, monkeypatch):
"""shipping_notice hybrid Agent 应注入含 refs 的 agent_runtime_context。"""
"""
shipping_notice hybrid Agent 应注入含 task refs 的 agent_runtime_context。
关键断言:co8 后无 batch_no;focus_object 为单票任务。
"""
from app import db
from app.services.agent_registry.handlers.bootstrap import load_handlers
@@ -94,26 +98,28 @@ def test_hybrid_executor_injects_shipping_agent_runtime_context(app, monkeypatch
with app.app_context():
load_handlers()
batch = ShippingBatch(
batch_no='SB-START-001',
conversation_id='conv-shipping-start-001',
current_focus_task_no='SN-START-001',
file_count=1,
user = User(
username='start-inputs-ship',
email='start-inputs-ship@example.com',
role='user',
status='active',
)
task = ShippingTask(
db.session.add(user)
db.session.flush()
task = ShippingNotice(
task_no='SN-START-001',
batch=batch,
user_id=user.id,
conversation_id='conv-shipping-start-001',
source_type='manual',
process_status='created',
)
db.session.add_all([batch, task])
db.session.add(task)
db.session.commit()
ctx = ChatStreamContext(
query='继续',
display_query='继续',
user=SimpleNamespace(id=1),
user=SimpleNamespace(id=user.id),
agent=_agent(
agent_code='shipping_notice',
runtime_provider='hybrid',
@@ -125,18 +131,16 @@ def test_hybrid_executor_injects_shipping_agent_runtime_context(app, monkeypatch
adapter_hints={
'shipping_notice': {
'task_id': 'SN-START-001',
'batch_no': 'SB-START-001',
}
},
shipping_task_id='SN-START-001',
shipping_batch_no='SB-START-001',
)
list(stream_chat_via_executor(ctx))
payload = json.loads(captured['inputs'][AGENT_RUNTIME_CONTEXT_INPUT])
assert payload['agent_code'] == 'shipping_notice'
assert payload['refs']['task_no'] == 'SN-START-001'
assert payload['refs']['batch_no'] == 'SB-START-001'
assert 'batch_no' not in (payload.get('refs') or {})
assert payload['reference_context']['focus_object']['id'] == 'SN-START-001'