Workflows
Five workflow patterns, each a bounded graph of policy-routed steps that writes one stitched trace.
Workflows
Five common shapes. Each tab shows the flow and the model every step routes to in this example; open Show flow_ir for the full, copyable term. Dry-run any flow with POST /x/flow/normalize first.
Triage cheap, draft to a quality floor, then a strong no-log guard that can refuse before anything ships.
Show flow_ir
["flow", {
"u": {"kind": "input"},
"t": {"kind": "llm", "system": "Classify the ticket and extract the account id as JSON.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["has_cap", "supports_json_mode"]],
["neg", ["normalize", ["field", "price_out"]]], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["u"]},
"d": {"kind": "llm", "system": "Write a reply using the ticket and the triage.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["cmp", "bench_intelligence", "ge", 0.55]],
["neg", ["normalize", ["field", "price_out"]]], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["u", "t"], "template": "Ticket:\n$1\n\nTriage:\n$2"},
"g": {"kind": "llm", "system": "Check brand voice, PII, refund limits. Refuse if any fail.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["is", "no_log"]],
["field", "bench_intelligence"], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["d"]},
"out": {"kind": "output", "inputs": ["g"]}
}]A cheap first draft, a strong critic, then a rewrite. A quality jump on a budget.
Show flow_ir
["flow", {
"u": {"kind": "input"},
"d": {"kind": "llm", "system": "Draft an answer.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["neg", ["normalize", ["field", "price_out"]]], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["u"]},
"c": {"kind": "llm", "system": "Critique the draft: list concrete flaws and gaps.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["field", "bench_intelligence"], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["d"]},
"r": {"kind": "llm", "system": "Rewrite the answer, fixing every point in the critique.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["field", "bench_intelligence"], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["u", "d", "c"], "template": "Question:\n$1\n\nDraft:\n$2\n\nCritique:\n$3"},
"out": {"kind": "output", "inputs": ["r"]}
}]N seeded draws from the same strong policy (sample spreads them across the top of the ranking), then a judge picks the best.
Show flow_ir
["flow", {
"u": {"kind": "input"},
"n1": {"kind": "llm", "system": "Answer the question.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["field", "bench_intelligence"], ["sample", 0.5], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["u"]},
"n2": {"kind": "llm", "system": "Answer the question.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["field", "bench_intelligence"], ["sample", 0.5], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["u"]},
"n3": {"kind": "llm", "system": "Answer the question.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["field", "bench_intelligence"], ["sample", 0.5], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["u"]},
"j": {"kind": "llm", "system": "Pick the single best candidate; return it verbatim.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["field", "bench_intelligence"], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["n1", "n2", "n3"], "template": "A:\n$1\n\nB:\n$2\n\nC:\n$3"},
"out": {"kind": "output", "inputs": ["j"]}
}]Three models pinned by family draft in parallel; a fourth synthesizes the best single answer. Each pin uses family_eq + a constant zero scorer (the filter already leaves one family).
Show flow_ir
["flow", {
"u": {"kind": "input"},
"a": {"kind": "llm", "system": "Draft an answer.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["family_eq", "gemini-3.1-pro-preview"]],
["zero"], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]], "inputs": ["u"]},
"b": {"kind": "llm", "system": "Draft an answer.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["family_eq", "claude-opus-4-8"]],
["zero"], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]], "inputs": ["u"]},
"c": {"kind": "llm", "system": "Draft an answer.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["family_eq", "deepseek-v4-flash"]],
["zero"], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]], "inputs": ["u"]},
"f": {"kind": "llm", "system": "Synthesize the single best answer from the drafts.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["add", ["scale", 0.7, ["normalize", ["field", "bench_intelligence"]]],
["scale", 0.3, ["neg", ["normalize", ["field", "price_in"]]]]],
["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["a", "b", "c"]},
"out": {"kind": "output", "inputs": ["f"]}
}]A reasoner and a coder run in parallel under different filters, then a merge step fuses them, for mixed reasoning-and-code tasks.
Show flow_ir
["flow", {
"u": {"kind": "input"},
"rz": {"kind": "llm", "system": "Reason through the problem step by step.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["is", "cap_reasoning"]],
["field", "bench_intelligence"], ["argmax"], ["id"], ["always", {"action": "next_candidate"}]], "inputs": ["u"]},
"cd": {"kind": "llm", "system": "Produce any code the problem needs.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]], ["cmp", "bench_coding_rank", "le", 5]],
["add", ["scale", 0.7, ["normalize", ["field", "bench_coding"]]],
["scale", 0.3, ["neg", ["normalize", ["field", "price_out"]]]]],
["argmax"], ["id"], ["always", {"action": "next_candidate"}]], "inputs": ["u"]},
"m": {"kind": "llm", "system": "Merge the reasoning and the code into one answer.",
"policy": ["policy", ["and", ["meets_req"], ["not", ["is", "disabled"]]],
["add", ["scale", 0.6, ["normalize", ["field", "bench_intelligence"]]],
["scale", 0.4, ["neg", ["normalize", ["field", "price_out"]]]]],
["argmax"], ["id"], ["always", {"action": "next_candidate"}]],
"inputs": ["rz", "cd"], "template": "Reasoning:\n$1\n\nCode:\n$2"},
"out": {"kind": "output", "inputs": ["m"]}
}]