SSyncropel Docs
Inference

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

PatternOne-linerTypical use
single_shotAsk the top-ranked responders once, combine, save.Most queries. Default.
verifyPrimary answers, verifier checks, tiebreaker resolves disagreement.Code review, legal opinion, any "get a second opinion" flow.
waterfallStages tried in order, stop at first acceptable.Cost cascade (pattern → cheap LLM → expensive LLM).
retry_on_low_confidenceIf confidence in the result is too low, retry with different settings.High-stakes extraction where underconfidence is recoverable.
escalateTiers of increasing authority. LLM → better LLM → human.Support triage, medical advice, any flow where "ask a human" is the backstop.
ensemble_with_auditAsk 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:

  1. Finds the eligible responders and ranks them.
  2. Sends a request to each top-ranked responder at the same time.
  3. Waits for the responses (until the timeout or min_quorum).
  4. Combines them.
  5. 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 carries eta_seconds, and Syncropel waits that much longer. It does NOT count toward min_quorum.
  • infer.decline.v1: "I can't." It carries reason: "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. Include body._confidence and body._rationale when 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:

KindTypical delayDefault max_latency_secs
pattern0.1s10s
system5s60s
llm30s300s
actor24h7 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:

  1. Responder conditions: each responders[].expression can be any CEL condition about the responder. (This works with every pattern, including single_shot.)
  2. Combining: ensemble_weighted.weight_expression, and fold.expression for the expression function.
  3. Thresholds: verify.agreement_threshold (a number by default), retry_on_low_confidence.threshold_expression, escalate.escalation_expression, ensemble_with_audit.audit_expression, and waterfall.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:

PatternBody kind
verifyinfer.orchestration.verify.state.v1
waterfallinfer.orchestration.waterfall.state.v1
retry_on_low_confidenceinfer.orchestration.retry.state.v1
escalateinfer.orchestration.escalate.state.v1
ensemble_with_auditinfer.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 needReach for
The common case: parallel fan-out, pick bestsingle_shot
Independent second opinion + tiebreakerverify
Cheap-to-expensive stop-early cost cascadewaterfall
Recovery from underconfident first attemptretry_on_low_confidence
LLM → better LLM → human fallbackescalate
Ensemble + trusted auditensemble_with_audit
Anything elseNested queries via event triggers

See also

On this page