Branching Pattern
Это содержимое пока не доступно на вашем языке.
Purpose
Section titled “Purpose”Route workflow execution to different paths based on user choice, collected data, or computed conditions.
Structure
Section titled “Structure”[get-choice] → [route] → choice=A → [path-a] → [merge] → choice=B → [path-b] → [merge]Implementation
Section titled “Implementation”Choice Collection
Section titled “Choice Collection”{ "type": "agent-directive", "id": "get-action", "directive": "Ask user: create new or edit existing?", "inputSchema": { "type": "object", "properties": { "action": { "type": "string", "enum": ["create", "edit"] } }, "required": ["action"] }, "connections": { "success": "route-action" }}Simple Binary Route
Section titled “Simple Binary Route”{ "type": "condition", "id": "route-action", "condition": { "operator": "eq", "left": { "contextPath": "action" }, "right": "create" }, "connections": { "true": "create-workflow", "false": "edit-workflow" }}Multi-Way Branching
Section titled “Multi-Way Branching”For more than 2 options, chain conditions:
{ "id": "check-create", "type": "condition", "condition": { "operator": "eq", "left": { "contextPath": "action" }, "right": "create" }, "connections": { "true": "create-branch", "false": "check-edit" }}{ "id": "check-edit", "type": "condition", "condition": { "operator": "eq", "left": { "contextPath": "action" }, "right": "edit" }, "connections": { "true": "edit-branch", "false": "delete-branch" }}Branching by Boolean Flag
Section titled “Branching by Boolean Flag”{ "type": "condition", "id": "check-has-tests", "condition": { "operator": "eq", "left": { "contextPath": "has_tests" }, "right": "yes" }, "connections": { "true": "run-tests", "false": "skip-tests" }}Branching by Numeric Value
Section titled “Branching by Numeric Value”{ "type": "condition", "id": "check-error-count", "condition": { "operator": "gt", "left": { "contextPath": "error_count" }, "right": 0 }, "connections": { "true": "fix-errors", "false": "proceed" }}Complex Conditions
Section titled “Complex Conditions”Combine multiple checks:
{ "condition": { "operator": "and", "conditions": [ { "operator": "eq", "left": { "contextPath": "status" }, "right": "ready" }, { "operator": "gt", "left": { "contextPath": "items_count" }, "right": 0 } ] }}Merging Branches
Section titled “Merging Branches”Branches typically converge at a common node:
[create-branch] → [save-workflow][edit-branch] → [save-workflow]Both paths connect to the same target node.
Related Patterns
Section titled “Related Patterns”- Information Collection - Collect data for routing decisions
- Skip Pattern - Special case of branching for optional steps