Orchestration Patterns
The six ways to run a query in steps (single_shot, verify, waterfall, retry_on_low_confidence, escalate, ensemble_with_audit), and how to chain queries when none fits.
Overview
Orchestration decides how many requests to send, in what order, and what to do with the responses before they are combined.
There are six patterns. If none fits, the answer is almost always to chain queries, not to write custom logic.
This guide covers each pattern, when to use it, how progress is saved between steps, and where you can use CEL expressions.
The six patterns
| Pattern | One-liner | Typical use |
|---|---|---|
single_shot | Ask the top-ranked responders once, combine, save. | Most queries. Default. |
verify | Primary answers, verifier checks, tiebreaker resolves disagreement. | Code review, legal opinion, any "get a second opinion" flow. |
waterfall | Stages tried in order, stop at first acceptable. | Cost cascade (pattern → cheap LLM → expensive LLM). |
retry_on_low_confidence | If confidence in the result is too low, retry with different settings. | High-stakes extraction where underconfidence is recoverable. |
escalate | Tiers of increasing authority. LLM → better LLM → human. | Support triage, medical advice, any flow where "ask a human" is the backstop. |
ensemble_with_audit | Ask several in parallel, then have a trusted responder audit the combined result. | Compliance decisions, financial advice, anything audit-critical. |
Pattern: single_shot
The default. Syncropel:
- Finds the eligible responders and ranks them.
- Sends a request to each top-ranked responder at the same time.
- Waits for the responses (until the timeout or
min_quorum). - Combines them.
- Saves the answer.
There are no extra steps and no escalation. If you don't choose a pattern, this runs.
{ "orchestration": { "pattern": "single_shot" } }Pattern: verify
The primary responder answers. The verifier answers independently. If their answers agree within agreement_threshold, that answer is saved. If not, the tiebreaker is asked and its answer is saved.
{
"orchestration": {
"pattern": "verify",
"primary": [{ "kind": "llm", "model": "~sonnet" }],
"verifier": { "kind": "llm", "model": "~gpt-4" },
"tiebreaker": { "kind": "actor", "did": "did:example:alice" },
"agreement_threshold": 0.85
}
}Agreement is measured by how similar the answers are. By default, structured answers must match exactly. Text can be compared by meaning instead.
Saved progress: after the primary and verifier respond, a record with body.kind: "infer.orchestration.verify.state.v1" and the agreement score is saved on the query thread. If the server stops partway, it resumes from there.
Cost: usually 2 CALLs (primary + verifier), and 3 only when they disagree.
Pattern: waterfall
Stages are tried in order. Each stage is a group of responders. Syncropel asks stage 1's top responders, combines their answers, and checks accept_expression against the result. If it passes, the answer is saved. Otherwise it moves to stage 2.
{
"orchestration": {
"pattern": "waterfall",
"stages": [
{ "responders": [{ "kind": "pattern", "capability": "summary" }] },
{ "responders": [{ "kind": "llm", "model": "~haiku" }] },
{ "responders": [{ "kind": "llm", "model": "~sonnet" }] }
],
"accept_expression": "fold.answer.confidence >= 0.85"
}
}Saved progress: each failed stage saves a record with body.kind: "infer.orchestration.waterfall.state.v1", holding the stage number, the result, and the check. After a restart, it resumes at the next stage.
Cost: minimum = stage 1 cost. Maximum = sum of all stages. You're betting most queries land at stage 1 or 2; the expensive fallback stages pay off rarely.
Pattern: retry_on_low_confidence
Runs single_shot. If the confidence of the result (from the chosen response's body.confidence) is below a threshold, it retries with a different dial, budget, or responders. You set the maximum number of attempts.
{
"orchestration": {
"pattern": "retry_on_low_confidence",
"threshold_expression": "fold.answer.confidence < 0.7",
"max_attempts": 3,
"retry_dial": 0.6
}
}Saved progress: each attempt saves a record with body.kind: "infer.orchestration.retry.state.v1", holding the attempt number, the result, and why it retried, including any dial change.
Cost: variable. If the first attempt is confident, you paid for one round. If all retries fire, you paid for max_attempts.
Pattern: escalate
Tiers of increasing authority. Syncropel runs tier 1, checks an expression, and moves to tier 2 if the expression is true. Tier 2 moves to tier 3 the same way. A typical 3-tier escalation is a model, then a stronger model, then a person.
{
"orchestration": {
"pattern": "escalate",
"tiers": [
{ "responders": [{ "kind": "llm", "model": "~haiku" }] },
{ "responders": [{ "kind": "llm", "model": "~sonnet" }] },
{ "responders": [{ "kind": "actor", "did": "did:example:alice" }] }
],
"escalation_expression": "fold.answer.confidence < 0.7"
}
}When the final tier is a person: they are notified through their chosen channel: a live notification if the app is open, otherwise a webhook, Pushbullet, Slack or SMS, a digest email if max_latency_secs > 3600, or polling as a fallback. See the section below.
Saved progress: each tier saves a record with body.kind: "infer.orchestration.escalate.state.v1".
Cost: bounded by tier count. Worst case you pay every tier.
When a person answers
A person can reply in three ways:
infer.accept.v1: "I'll take it." It carrieseta_seconds, and Syncropel waits that much longer. It does NOT count towardmin_quorum.infer.decline.v1: "I can't." It carriesreason: "out_of_domain" | "overbooked" | "conflict_of_interest" | "other". It does not count toward quorum, and the query continues with whoever else responded.- Submit: the answer itself, with a body matching
answer_shape.kind. It is included when answers are combined. Includebody._confidenceandbody._rationalewhen you can.
A person's availability (availability.status, availability.hours, availability.typical_response_delay_s, availability.last_seen_at) is used when ranking, so a query doesn't go to someone who is away. If typical_response_delay_s > max_latency_secs × 0.5, that person is skipped.
Default time limits by responder kind:
| Kind | Typical delay | Default max_latency_secs |
|---|---|---|
pattern | 0.1s | 10s |
system | 5s | 60s |
llm | 30s | 300s |
actor | 24h | 7 days |
Pattern: ensemble_with_audit
Asks several primary responders at the same time, combines their answers, then sends the combined result to a trusted auditor to review. The saved answer includes both the result and the audit verdict.
{
"orchestration": {
"pattern": "ensemble_with_audit",
"primary_responders": [
{ "kind": "llm", "model": "~sonnet" },
{ "kind": "llm", "model": "~gpt-4" },
{ "kind": "llm", "model": "~gemini" }
],
"auditor": { "kind": "actor", "did": "did:example:compliance-officer" },
"audit_expression": "audit.approved == true"
}
}If the auditor approves, the combined result is saved. If they reject, a record with body.audit.rejected: true and the auditor's reasoning is saved instead. obligation_resolution: "validation_error" is common here, so any ambiguity stops the query instead of silently letting the last writer win.
Saved progress: body.kind: "infer.orchestration.audit.state.v1".
Cost: N primary CALLs + 1 audit CALL. The audit CALL is typically the expensive one (if the auditor is human).
Where you can use CEL
You can't script the patterns themselves. But you can use a CEL expression in three places:
- Responder conditions: each
responders[].expressioncan be any CEL condition about the responder. (This works with every pattern, includingsingle_shot.) - Combining:
ensemble_weighted.weight_expression, andfold.expressionfor theexpressionfunction. - Thresholds:
verify.agreement_threshold(a number by default),retry_on_low_confidence.threshold_expression,escalate.escalation_expression,ensemble_with_audit.audit_expression, andwaterfall.accept_expression.
There are no if blocks or loops. If you need something else, chain queries.
Saved progress
Every multi-step pattern saves its progress as records on the query's thread. The body kinds are:
| Pattern | Body kind |
|---|---|
verify | infer.orchestration.verify.state.v1 |
waterfall | infer.orchestration.waterfall.state.v1 |
retry_on_low_confidence | infer.orchestration.retry.state.v1 |
escalate | infer.orchestration.escalate.state.v1 |
ensemble_with_audit | infer.orchestration.audit.state.v1 |
These records hold enough to resume after a restart. Because progress is saved, even a human escalation that takes 7 days survives a restart.
If you restore the query thread on another instance, the query carries on from where it stopped. A person who hasn't answered yet is still waited for.
Nested queries: going beyond the six patterns
A query's KNOW record can be the input.record_id of another query. This is how you go beyond the six patterns.
Example: "classify this document, then summarise only if the classification is 'research'":
Query A (classification):
{
"kind": "infer.query.v1",
"input": { "inline": "<document>" },
"responders": [{ "kind": "llm", "model": "~sonnet" }],
"fold": { "function": "best_of" },
"answer_shape": { "kind": "core.classification.v1" }
}When A's answer is saved, an event trigger fires on body.kind == "core.classification.v1" and body.category == "research". The trigger writes a new INTEND:
Query B (summarisation):
{
"kind": "infer.query.v1",
"input": { "record_id": "<A's KNOW id>" },
"responders": [
{ "kind": "llm", "model": "~sonnet" },
{ "kind": "llm", "model": "~gpt-4" }
],
"fold": { "function": "consensus" },
"answer_shape": { "kind": "core.summary.v1" }
}The chain A → B is two records, each citing the one before it. You can chain as many queries as you like (A → B → C), with conditions at each step.
Choosing a pattern
| You need | Reach for |
|---|---|
| The common case: parallel fan-out, pick best | single_shot |
| Independent second opinion + tiebreaker | verify |
| Cheap-to-expensive stop-early cost cascade | waterfall |
| Recovery from underconfident first attempt | retry_on_low_confidence |
| LLM → better LLM → human fallback | escalate |
| Ensemble + trusted audit | ensemble_with_audit |
| Anything else | Nested queries via event triggers |
See also
- Query Anatomy: Orchestration: field reference.
- Fold Functions: the ways answers are combined.
- Event triggers: how to wire nested-query chains.
- CEL Expressions: syntax for threshold / acceptance expressions.
- Actors and adapters: how human and system responders are registered.
Fold Functions
The five fold functions that combine answers from several responders into one: consensus, best_of, waterfall_first, ensemble_weighted, and expression. Each gives the same result for the same answers.
Routing Rules
Control which actor handles which records: match on domain and act, set targets, and let your approvals become rules.