Markdown Workflow Branches

Route markdown-workflow steps based on step output

Markdown workflows branch on any step’s output — jump to a labelled step instead of running linearly.

Diagram

Markdown Branch

success

failure

📝 Request

🤖 step1: Classify

branch match?

✅ handle_success

❌ handle_failure

Quick Start

  1. Write a branching workflow
    .praisonai/workflows/classify.md
    ---
    name: classify
    ---
    
    ## step1
    Classify the request as success or failure.
    
    ```branch
    success: [handle_success]
    failure: [handle_failure]
    ```
    
    ## handle_failure
    Escalate the request.
    
    ## handle_success
    Reply to the request.
  2. Run it
    bash
    praisonai workflow run .praisonai/workflows/classify.md

    When step1‘s output contains success, execution jumps to handle_success and skips handle_failure.


How It Works

WorkflowManager evaluates each step’s branch_condition against that step’s output, then jumps to the first matching next step.

Diagram
StepWorkflowManagerUserStepWorkflowManagerUserpraisonai workflow run classify.mdRun step1Output “…success…”Match branch_conditionJump to handle_successReplyResult
ConceptWhere it livesBehavior
branch blockFenced block under a stepMaps a match value → [next_steps]
next_stepsFrontmatter keySteps to run if no branch matches
Match ruleStep outputFirst key found in the output wins

Configuration Options

OptionFormDescription
`branch Fenced blockDict of match: [next_steps]
next_steps:Frontmatter keyFallback next steps if no branch matches
Task(routing=...)PythonEquivalent via TaskRoutingConfig(branches=..., next_steps=...)

Equivalent Python:

python
from praisonaiagents import Task
from praisonaiagents.workflows.workflow_configs import TaskRoutingConfig

Task(
    name="step1",
    description="Classify the request",
    routing=TaskRoutingConfig(
        branches={"success": ["handle_success"], "failure": ["handle_failure"]},
    ),
)

Common Patterns

Success/failure classifier — jump to a handler based on outcome:

markdown
## step1
Classify as success or failure.

```branch
success: [handle_success]
failure: [handle_failure]
```

Score-based fanout — route on a threshold match in the output:

markdown
## score
Score the submission and state "premium" or "standard".

```branch
premium: [premium_path]
standard: [standard_path]
```

No-op fallback — when nothing matches, execution continues linearly to the next step, so a missing branch never stalls the workflow.


Best Practices

Name branch targets after real steps

Every value in a branch block must reference an existing ## step. Undefined targets are skipped.

Make the match value explicit in step output

Instruct the step to state the match keyword clearly (“Reply with success or failure”) so the branch matches reliably.

Keep one branch block per step

Use a single branch block per step for a clear one-to-many jump. Use next_steps frontmatter for the default path.


Related