TarskiTarski/ docsJoin the waitlist

The agent query relay

How an LLM agent reads the worldview through a proposal, a decision, an admitted intent, a governed effect, and results that re-enter as gated evidence.

A model never queries anything directly. It requests named declared queries, and ordinary Tarski decision rules ratify or deny each request. An admitted intent executes the read at a pinned head under the interface’s projection, and the result re-enters the lineage as an observation that feeds the next turn. Reads get the same governance as writes, and the whole path replays deterministically.

The read loop

  1. The model requests reads. The platform composes a reserved query-request section into each relay-participating interface’s response schema. The model’s reply may carry an array of (query_name, bindings). Only agent-exposed declared queries can be named, and free-form query text is refused.
  2. The runtime captures the request as a proposal. It stamps a relay envelope on the model-call result and derives typed proposal atoms with no mapper involved: proposal.query_requested.<query_name>(…) carrying the binding values.
  3. Your rules decide. They approve or deny by joining on binding values, sessions, consent facts, and budgets. Approval is never implicit. Even trivial approval is an explicit, auditable rule.
  4. Approved requests are admitted. intent.query_execute derives only from committed decisions. The admitted intent pins the full execution contract: query digest, canonical bindings, head, and projection identity. Pinned query IR is durably retained, so hot-reload between admission and execution can never swap in a different query.
  5. The read executes. The worldview.query effect runs the engine at the pinned head under the interface’s projection. Success appends a worldview.query_result observation, and failure appends typed worldview.query_failed, so rules can react to failed reads.
  6. Results stay gated. queryresult.outcome rows are trusted lifecycle metadata (session, request id, digests, and outcome class, but never row contents). The data rows queryresult.<query_name> are fallible-relay-class. They cannot support a trusted fact without decision.accepted.* or an intent without decision.approved.*. Even the single bit that a query was non-empty cannot affect the world without an approval.

Independent reads batch into one turn and execute concurrently at the same head. The proposal and result families are system-owned. App declarations or mapper writes into them are load errors, and externally submitted observations claiming those kinds are rejected at ingress. Identity is replay-deterministic (request ids derive from the capture digest), so a clean-store replay reproduces an entire multi-hop deliberation with identical digests.

Wiring it in the manifest

[capabilities]
worldview_query = true

[capabilities.intents."intent.query_execute"]
capability = "worldview.query"
identity_keys = ["session_id", "request_id"]

Relay-participating llm.complete bindings name their interface, which binds the session contract and projection. Consultation bindings set model_consultation = true. This narrow exception lets trusted queryresult.outcome lifecycle rows drive a follow-up model turn.

Budgets and denials

Budgets are ordinary decision rules:

-- two reads per session; deny with a reason a PM can read
decision.rejected.triage.query_execute(session, req, "budget_exhausted") :-
  proposal.query_requested.impacted_services(session, req, root),
  triage.session_query_count(session, n),
  n >= 2.

An invariant (admitted query intents per session ≤ budget) backs up the budget rule and makes over-approval an impossible state. Denial reports flow into the session’s next-turn context, so the model learns that a read was refused and why.

Authoring patterns

  • Any model-consultation turn that re-derives over queryresult.outcome must be guarded on “no unsettled requests in the session”. Without this consultation guard, the changing results section re-admits the producing turn every round and the agent loops.
  • Prefer compound queries to multi-hop reads. Queries are full Datalog programs, so pre-join in one declared query and avoid chaining reads.
  • Prove the loop with fixtures. tarski fixture template query-relay <query> generates a complete request/result lifecycle, and digest refresh keeps recorded identities current. The incident-response example ships fixtures for approved, denied, budget-exhausted, and failed reads.

Curated model context

Each turn’s context is assembled in a prefix-stable order: the prompt bundle, the ontology schema section (“the menu of reads”), the declared ambient world slice, the session’s query-results section (results and denials), and the request arguments. Every section is digest-stamped and joined into the provider request digest. New results change only the tail, so provider prompt caches stay warm. Studio’s model-turn context manifest and GET /v1/queries/turns/{turn_id}/context disclose what a turn saw.