feat(shipping-notice): 收敛订单处理状态与履约门禁
This commit is contained in:
1 parent
bffcd55b40
commit
70dd0051b8
153 files changed
+10916
-4296
No files matched your search
@@ -2,7 +2,7 @@
|
||||
services/shipping_notice/tool_response.py
|
||||
|
||||
用途:统一构建发货通知 Tool 的 JSON 响应结构。
|
||||
依赖:state_machine 中的 checkpoint 解析能力;ShippingProcessExecution。
|
||||
依赖:state_machine.resolve_task_ui_state(位置派生);ShippingProcessExecution。
|
||||
逻辑:由 task_workflow、inventory_workflow、fulfillment_workflow 等 workflow 调用本文件,把状态机信息整理成一致的 Tool 响应;
|
||||
已绑定 ProcessExecution 的任务不再下发旧动作字段(恢复仅由 Gate 驱动)。
|
||||
"""
|
||||
@@ -83,7 +83,7 @@ def tool_response(
|
||||
data: dict[str, Any] | None = None,
|
||||
human_options: list[str] | None = None,
|
||||
action_buttons: list[dict[str, str]] | None = None,
|
||||
checkpoint: str | None = None,
|
||||
position: str | None = None,
|
||||
next_required_action: str | None = None,
|
||||
forbidden_next_tools: list[str] | None = None,
|
||||
stop_agent_turn: bool = False,
|
||||
@@ -92,11 +92,12 @@ def tool_response(
|
||||
"""
|
||||
构建发货通知 Tool 标准 JSON 响应。
|
||||
|
||||
核心逻辑:未显式传 checkpoint 时从 task DB 状态推导 checkpoint;
|
||||
显式 checkpoint 优先(如 parse_ok、task_exists)。
|
||||
若任务已有 ProcessExecution:不再填充旧动作字段,避免与 Gate 双真相。
|
||||
核心逻辑:未显式传 position 时从 task 派生位置;显式 position 优先
|
||||
(如 parse_ok、task_exists)。若任务已有 ProcessExecution:不再填充旧动作字段,
|
||||
避免与 Gate 双真相。
|
||||
|
||||
Args:
|
||||
position: 进程位置标签;None 时从 resolve_task_ui_state(task).position 推导。
|
||||
stop_agent_turn: True 时要求 Agent 本回合停止,等待用户操作。
|
||||
forbidden_next_tools: 禁止 Agent 同轮调用的 Tool 名称列表。
|
||||
extra: 需要保留在顶层的额外业务字段。
|
||||
@@ -109,12 +110,12 @@ def tool_response(
|
||||
gate_owns_recovery = _task_has_process_execution(task)
|
||||
# action_buttons 是历史调用参数,仅为兼容调用方签名;绝不进入对外响应。
|
||||
del action_buttons
|
||||
resolved_checkpoint = checkpoint
|
||||
resolved_position = position
|
||||
# 旧 human_options 参数仅保留调用签名兼容,绝不返回。用户动作必须由 Gate DTO 授权。
|
||||
del human_options
|
||||
if checkpoint is None and task is not None:
|
||||
if position is None and task is not None:
|
||||
ui = resolve_task_ui_state(task)
|
||||
resolved_checkpoint = ui.checkpoint
|
||||
resolved_position = ui.position
|
||||
|
||||
payload: dict[str, Any] = {
|
||||
"status": status,
|
||||
@@ -124,8 +125,8 @@ def tool_response(
|
||||
if task_id:
|
||||
payload["task_id"] = task_id
|
||||
# [STEP] 业务按钮统一由 ui_state.actions 返回;Tool 响应不再生成旧 human_options/action_buttons。
|
||||
if resolved_checkpoint:
|
||||
payload["checkpoint"] = resolved_checkpoint
|
||||
if resolved_position:
|
||||
payload["position"] = resolved_position
|
||||
if next_required_action and not gate_owns_recovery:
|
||||
payload["next_required_action"] = _sanitize_user_facing_text(next_required_action)
|
||||
if forbidden_next_tools:
|
||||
|
||||
Reference in new issue
Block a user