feat: make workflow messages resumable

This commit is contained in:
Xin Wang
2026-08-03 07:54:51 +08:00
parent e3035abcc2
commit f5c36a62aa
10 changed files with 423 additions and 175 deletions

View File

@@ -10,7 +10,7 @@ from typing import Any
SPEC_VERSION = "3"
NODE_TYPES = {"start", "agent", "message", "action", "handoff", "end"}
EDGE_MODES = {"llm", "expression", "always"}
AGENT_ENTRY_MODES = {"wait_user", "generate", "fixed_speech"}
AGENT_ENTRY_MODES = {"wait_user", "generate"}
ACTION_RESULT_ASSIGNMENT_MODES = {"inherit", "override", "none"}
ACTION_USER_INPUT_POLICIES = {"queue", "block"}
AUTOMATIC_NODE_TYPES = {"start", "message", "action", "handoff"}
@@ -149,10 +149,11 @@ def _edge_data_v3(edge: dict) -> dict:
def _normalize_agent_data(data: dict[str, Any]) -> None:
"""Add v3 Agent defaults without changing existing node-level behavior."""
"""Keep Agent entry focused on conversation, not fixed interaction."""
data.setdefault("contextPolicy", "inherit")
data.setdefault("entryMode", "wait_user")
data.setdefault("entrySpeech", "")
if data.get("entryMode") not in AGENT_ENTRY_MODES:
data["entryMode"] = "wait_user"
data.pop("entrySpeech", None)
if "inheritGlobalConfig" not in data:
has_node_overrides = any(
(
@@ -300,7 +301,6 @@ def normalize_graph(graph: dict[str, Any] | None) -> dict[str, Any]:
"contextPolicy": "inherit",
"inheritGlobalConfig": True,
"entryMode": "wait_user",
"entrySpeech": "",
},
}
)
@@ -376,10 +376,6 @@ def validate_graph(graph: dict[str, Any]) -> list[str]:
entry_mode = data.get("entryMode", "wait_user")
if entry_mode not in AGENT_ENTRY_MODES:
errors.append(f"Agent 节点 {node_id} 的进入模式无效:{entry_mode}")
elif entry_mode == "fixed_speech" and not str(
data.get("entrySpeech") or ""
).strip():
errors.append(f"Agent 节点 {node_id} 的固定进入语不能为空")
elif node_type == "message":
data = node.get("data") or {}
speech = data.get("speech")