A workflow step handler that executes multiple branches based on conditional logic. Use this to implement parallel or conditional task routing in automated workflows.
// Source: https://github.com/VoltAgent/voltagent | License: MIT | Copyright 2025 VoltAgent Inc
// Provided via justclaw.it.com; keep this notice with the code.
import type { Span } from "@opentelemetry/api";
import { defaultStepConfig } from "../internal/utils";
import { matchStep } from "./helpers";
import { throwIfAborted } from "./signal";
import type { WorkflowStepBranch, WorkflowStepBranchConfig } from "./types";
/**
* Creates a branching step that runs all steps whose conditions match.
*/
export function andBranch<INPUT, DATA, RESULT>({
branches,
...config
}: WorkflowStepBranchConfig<INPUT, DATA, RESULT>) {
return {
...defaultStepConfig(config),
type: "branch",
branches,
execute: async (context) => {
const { state } = context;
const traceContext
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key