SSyncropel Docs
Inference

Query Anatomy

Every field of an infer.query.v1 query, with types and defaults, and worked examples for a single model, a consensus ensemble, and the verify pattern.

Overview

An infer.query.v1 body is checked against a published JSON Schema. This page covers every field. For the schema itself, see the schema reference.

Every query has four required parts: input (what to answer), responders (who may answer), answer_shape (what the result must look like) and fold (how answers combine). Everything else is optional and has a default.

Minimal query

The smallest complete query:

{
  "kind": "infer.query.v1",
  "input": { "inline": "What is 2 + 2?" },
  "responders": [{ "kind": "llm", "model": "~sonnet" }],
  "fold": { "function": "best_of" },
  "answer_shape": { "kind": "core.text.v1" }
}

That dispatches one CALL to any Claude Sonnet responder, takes its answer as best_of (since there is only one), and saves it as a KNOW record with body kind core.text.v1.

Top-level fields

FieldTypeRequiredDefault
kindliteral "infer.query.v1"yesNone
inputInput (oneOf three shapes)yesNone
answer_shapeAnswerShapeyesNone
respondersResponderPredicate[] (min 1)yesNone
foldFoldyesNone
dialnumber 0–1 OR AdaptiveDialno0.5
orchestrationOrchestrationno{ pattern: "single_shot" }
side_effectsSideEffectsnonamespace defaults
relevanceRelevanceno{ model: "current", threshold: 0.5, top_k: 3 }
metadatamap of string to stringno{}

Input

Exactly one of three shapes:

{ "inline": <any JSON>, "inline_kind": "core.text.v1" }

or a reference to an existing record by id:

{ "record_id": "3fa8...e2c1" }

or a reference to an entity by canonical ref (any of the 11 Ref.* shapes; see the schema reference):

{ "ref": { "kind": "@music.track", "id": "spotify:track:4iV5W9uYEdYUVa79Axb7Rh" } }

When you use inline, the same input always gives the same query ID, so you can reuse results across sessions. The optional inline_kind lets Syncropel apply processing specific to that kind of content.

Answer Shape

Checks the combined result, not individual responses. Responders can return whatever they like; only the final result must match answer_shape.

{
  "kind": "core.translation.v1",
  "required_fields": ["body.text", "body.target_language"],
  "schema_ref": "https://example.com/translation.schema.json"
}
  • kind (required): the body.kind of the result, such as core.translation.v1.
  • required_fields (optional): dot-paths that must be present (not null) in the result.
  • schema_ref (optional): URI of a full JSON Schema. If present, the result is validated against it.

If the result doesn't match, you get an infer.error.v1 record with code: "answer_shape_mismatch" instead of an answer. The query thread shows the result that failed and why.

Responder Predicates

The responders array lists groups of responders. A responder that matches any entry is eligible. Each entry looks like this:

{
  "kind": "llm",
  "model": "~sonnet",
  "trust_gte": 0.6,
  "budget_usd": 0.05,
  "latency_secs": 30,
  "match_level_gte": "L2",
  "age_days_lt": 7,
  "available": true,
  "domain": "translation",
  "capability": "en-es",
  "did": "did:sync:agent:translate-bot",
  "expression": "candidate.last_seen_at > now() - 86400"
}

All fields are optional. Within one entry, a responder must meet every field you set. Across entries, matching any one is enough.

Responder kinds:

kind valueWhat it selects
actorHuman actors or named agents
llmAI model providers (combine with model)
patternSaved patterns
systemSystem adapters (registered programs, HTTP services)
anyAny responder that meets the other fields
(via expression)Any condition you write in CEL

Worked example: two kinds of responder:

"responders": [
  { "kind": "llm", "model": "~sonnet", "trust_gte": 0.7, "budget_usd": 0.05 },
  { "kind": "actor", "did": "did:example:alice", "capability": "code-review" }
]

That matches any Sonnet-family LLM with trust at least 0.7 and per-call cost under 5 cents, OR Alice specifically when her capability tag is code-review.

Fold

How answers are combined. See Fold Functions for each function in detail.

{
  "function": "consensus",
  "weight_expression": "response.trust * response.recency",
  "tie_break": "highest_trust",
  "min_quorum": 2,
  "expression": "..."
}
FieldTypeDefaultApplies when
functionenumNone (required)always
weight_expressionCEL string"trust * recency * pattern_confidence"consensus, ensemble_weighted
tie_breakenum"highest_trust"any function
min_quorumint ≥ 11all functions
expressionCEL stringNone (required when function == "expression")expression

Enum values:

  • function: consensus, best_of, waterfall_first, ensemble_weighted, expression.
  • tie_break: highest_trust, highest_confidence, most_recent, lexicographic.

Orchestration

How the query is run in steps. See Orchestration Patterns for each pattern.

Default:

{ "pattern": "single_shot" }

Full shape for verify:

{
  "pattern": "verify",
  "primary": [{ "kind": "llm", "model": "~sonnet" }],
  "verifier": { "kind": "llm", "model": "~gpt-4" },
  "tiebreaker": { "kind": "actor", "did": "did:example:alice" },
  "agreement_threshold": 0.85
}

Patterns: single_shot, verify, waterfall, retry_on_low_confidence, escalate, ensemble_with_audit.

Side Effects

Cost and safety limits. Namespace-level defaults apply if unset (see namespaces).

{
  "reversible": true,
  "idempotent": true,
  "max_cost_usd": 0.40,
  "max_latency_secs": 1800,
  "obligation_resolution": "last_writer_wins"
}
FieldTypeDefaultNotes
reversiblebooltrueWhether responses modify state that can be rolled back
idempotentbooltrueWhether re-running produces the same side effects
max_cost_usdnumbernamespace capCumulative CALL cost ceiling; exceeded → cost_budget_exceeded error
max_latency_secsinteger300Longest time to wait for answers; exceeded → latency_timeout error
obligation_resolutionenumlast_writer_winsHow to resolve modifier conflicts (fulfills/cancels/awaits)

Obligation resolution values:

  • last_writer_wins: most recent response's modifiers win.
  • fulfills_wins: any response with body.fulfills preempts one with body.cancels.
  • validation_error: any conflict aborts the fold with obligation_conflict.

Relevance

Controls how eligible responders are ranked and trimmed.

{
  "model": "current",
  "threshold": 0.5,
  "top_k": 3
}
FieldDefaultNotes
model"current""current" uses the scorer you have registered; "heuristic" uses the built-in scoring
threshold0.5Candidates below this score are discarded
top_k3After threshold, keep the top k by score

If fewer than min_quorum responders remain, you get a no_relevant_candidates error.

Dial

The dial is a number between 0 and 1 that sets how willing Syncropel is to try something new (trust). Low values favour proven responders and patterns, and high values favour new ones. In a query, a higher dial makes ranking more willing to pick unfamiliar responders.

Scalar form:

{ "dial": 0.3 }

Adaptive form, using expressions checked against the responders when the query runs:

{
  "dial": {
    "replay_if": "pattern_match >= 'L1' && trust >= 0.92",
    "create_if": "pattern_match == null",
    "else": 0.4
  }
}

If replay_if matches, the dial is set to 0.1 (strongly favour proven answers). If create_if matches, it is set to 0.9 (strongly favour new ones). Otherwise else applies.

Metadata

A map of strings to strings that you own. Use it for trace IDs, customer IDs, feature flags: whatever you need to correlate queries across your own systems. Syncropel doesn't use it; it just copies it onto the answer.

{ "metadata": { "trace_id": "trace_abc123", "customer_id": "cust_42" } }

Worked example: single LLM

{
  "kind": "infer.query.v1",
  "input": { "inline": "Translate 'Hello' to Spanish." },
  "responders": [{ "kind": "llm", "model": "~sonnet" }],
  "fold": { "function": "best_of" },
  "answer_shape": { "kind": "core.translation.v1", "required_fields": ["body.text"] },
  "side_effects": { "max_cost_usd": 0.05, "max_latency_secs": 30 }
}

One responder, best_of (which simply picks the only answer), and a limit of 5 cents and 30 seconds.

Worked example: consensus ensemble

{
  "kind": "infer.query.v1",
  "input": { "inline": "Summarise: <paper abstract here>" },
  "responders": [
    { "kind": "llm", "model": "~sonnet" },
    { "kind": "llm", "model": "~gpt-4o" },
    { "kind": "llm", "model": "~gemini-1.5" }
  ],
  "fold": { "function": "consensus", "min_quorum": 2 },
  "answer_shape": {
    "kind": "core.summary.v1",
    "required_fields": ["body.rating", "body.summary"]
  },
  "relevance": { "top_k": 3 },
  "side_effects": { "max_cost_usd": 0.30, "max_latency_secs": 60 }
}

Asks three AI models at the same time, needs at least 2 to respond, and picks the answer most of them agree on.

Worked example: verify pattern

{
  "kind": "infer.query.v1",
  "input": { "record_id": "a1b2c3..." },
  "responders": [
    { "kind": "llm", "model": "~sonnet" },
    { "kind": "llm", "model": "~gpt-4" },
    { "kind": "actor", "did": "did:example:alice" }
  ],
  "fold": { "function": "best_of", "tie_break": "highest_trust" },
  "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
  },
  "answer_shape": { "kind": "core.code_review.v1" },
  "side_effects": { "max_cost_usd": 0.40, "max_latency_secs": 1800 }
}

Claude Sonnet does the primary review. GPT-4 verifies. If they disagree beyond the agreement threshold, Alice gets pulled in as tiebreaker. The saved answer is whichever one fold selects.

See also

On this page