fix: make multica workflow path deterministic

This commit is contained in:
2026-06-13 14:25:05 +08:00
parent b3ce64881d
commit 1bc89446bc
2 changed files with 30 additions and 26 deletions
@@ -57,7 +57,16 @@ def validate_fixture(fixture: Dict[str, Any]) -> Dict[str, int]:
for node in nodes
if isinstance(node, dict) and (node.get("data") or {}).get("agent_code")
}
node_by_id = {node.get("id"): node for node in nodes if isinstance(node, dict)}
node_types = {node.get("type") for node in nodes}
outgoing_edges: Dict[str, list[str]] = {}
for edge in edges:
if not isinstance(edge, dict):
continue
source = edge.get("source")
target = edge.get("target")
if source and target:
outgoing_edges.setdefault(source, []).append(target)
required_persona_fields = {
"role",
@@ -67,6 +76,7 @@ def validate_fixture(fixture: Dict[str, Any]) -> Dict[str, int]:
"examples",
}
required_node_types = {"start", "end", "template", "parallel", "merge"}
multi_outgoing_node_types = {"parallel", "condition", "intent", "choice"}
missing_workflow_agents = sorted(workflow_agent_codes - agent_codes)
missing_persona_fields = {
@@ -75,6 +85,12 @@ def validate_fixture(fixture: Dict[str, Any]) -> Dict[str, int]:
if required_persona_fields - set((agent.get("persona") or {}).keys())
}
missing_node_types = sorted(required_node_types - node_types)
invalid_multi_outgoing = {
source: targets
for source, targets in outgoing_edges.items()
if len(targets) > 1
and (node_by_id.get(source) or {}).get("type") not in multi_outgoing_node_types
}
project_manager = next(
(agent for agent in agents if agent.get("code") == "project_manager"),
None,
@@ -84,12 +100,14 @@ def validate_fixture(fixture: Dict[str, Any]) -> Dict[str, int]:
missing_workflow_agents
or missing_persona_fields
or missing_node_types
or invalid_multi_outgoing
or project_manager_workflow != "multica_org_collaboration_flow"
):
raise ValueError(
f"Fixture validation failed: missing_workflow_agents={missing_workflow_agents}, "
f"missing_persona_fields={missing_persona_fields}, "
f"missing_node_types={missing_node_types}, "
f"invalid_multi_outgoing={invalid_multi_outgoing}, "
f"project_manager_workflow={project_manager_workflow}"
)