Skip to main content
The context recipe of a judgment decides exactly what the engine reads for each answer: fields of the document, the start of a long field, its images, and the related documents that the question needs. It also decides which writes make Brussle judge the document again and what each answer costs. A payment, for example, has an amount, a reference, a payer and a long list of bank events. This recipe sends the first three with only the last three bank events:
The recipe decides three things:
  • Inputs. The engine answers only from what the recipe shows, and Brussle stores that exact text (with a reference to each image) with each answer. See check what the engine saw.
  • When Brussle judges again. Only a change to what the recipe reads judges the document again, so a change outside it judges nothing and costs nothing.
  • Cost. The tokens of the compiled context and the question decide each answer’s size class.
The recipe is part of the judgment’s definition, so a change to it makes a new version. A create needs a recipe, so Brussle refuses one without context and suggests a recipe from your documents (see when you leave out context).

Ask a narrow question, with the right document beside it

Ask about one document, and show the engine that document with only the related documents that the question is about. For each question, ask what a careful person needs to see to answer it, send only that, then check what the engine saw on a few documents.
  • One narrow question per document. The settles judgment, for example, asks about one payment and shows beside it the open invoices with the same customer and currency. Do not ask one broad question over many related documents.
  • Keep numbers as features. A count, a sum or the latest status of many related documents is a number rather than text, so put it in a relation’s aggregate with "render": false and name it in features. The engine does not read it, but Brussle records it with each answer and the fit on your outcomes weighs it. The document’s own numbers, ages and the engine’s previous answer can be features too (see what a feature can read).
  • For a question about what will happen, ask what the document shows now, since the engine does not forecast. The counts and the fit on your outcomes carry the number. See outcomes with a horizon.
This judgment reads one invoice and the customer’s last three messages about it, and keeps one count as a feature (the customer’s invoices paid late in the last year).
  • messages reads the documents that point at the invoice.
  • paid_late reads the invoices that share the customer’s key. When only its count changes, Brussle records the new count with no engine call.
  • horizon says that an outcome (whether the invoice went overdue) counts against the answer for 30 days. The fit weighs the engine’s answer and the count against it, and the calibration report shows what the engine adds to the count alone.

Which documents a judgment judges

applies_to, beside the recipe, decides which documents a judgment judges, answers and bills, so {"attributes.kind": "invoice"} judges only invoices. A judgment without it judges every document in the namespace, including the ones you write later, and the create response warns you.
  • Each key is an attribute, at most 8 keys, and all must match.
  • A single value matches when the attribute equals it. A list matches any of its values.
  • Other documents have no answer for the judgment.
  • applies_to is part of the definition, so a change to it makes a new version.

Cut a long field

A long field (an email body, or a call transcript) can decide the size class alone, so give its fields entry a max_chars and the engine sees only its start:
  • A longer string is cut to its first max_chars characters.
  • A value that fits goes unchanged with its type, so a number stays a number.
  • A longer array or object goes as its JSON text, cut to max_chars, as a string.
  • An image path is never cut. Brussle refuses max_chars on it with invalid_request.
  • Characters are Unicode code points, not bytes or tokens. max_chars is at least 1.
max_chars works in the recipe’s fields, in a relation’s fields (after any band) and in previous.fields, but Brussle refuses it in aggregates. An edit after the cut changes nothing that the engine reads from that field, so if nothing else that the engine reads changed, the answer stays and Brussle bills nothing. max_chars limits one field and does not make the whole context fit, so Brussle still cuts over max_tokens. A field cut by max_chars does not set context_truncated. related lets a judgment read other documents in its namespace, and Brussle keeps the answer current when any of them changes. A relation reads the documents that point at the judged document, the one it points at, the documents that share a key with it, or those a matching judgment linked to it. Relations in a recipe describes every key, what the engine sees and what is cut first, and judge a document with its related documents walks through one. For example, a payment reads the 10 newest open invoices in its block as text, and counts and sums all of them from the last 180 days:
An aggregate is a few tokens where raw text is hundreds, so use one when a question depends on volume more than on words. To let the fit weigh it, name it in features with "render": false.

The document the judged one points at

A relation with join: {"theirs": "id", "mine": "attributes.<name>"} reads the one document whose id is in the judged document’s attribute (an order line’s product, for example). A change to what the relation shows of that document judges again the documents that point at it, inside the judgment’s freshness.fanout scope. See the referenced document and judge a document with the document it points at.

Order

A relation keeps its newest documents by default, while order (such as {"by": "state.due", "desc": false}) keeps the documents that come first by a field you choose, among the newest 1,000. See pick documents with order.

Bands

A relation’s fields entry can show a number as its band, so a move inside a band changes nothing that the engine reads and costs nothing:
See show a number as a band.

Start from a starter

A starter judgment is a ready-made definition for a common question, with a question, type, recipe and suggested thresholds, and placeholders for your own paths. Most starters read related documents (a payment beside its customer’s open invoices), but a few, such as ticket triage, read only their own document. A starter shows how to organise your data and says nothing about whether its answers will be good on it, so measure them against your outcomes. Starter judgments lists each one, and GET /v1/starters returns the same list. To preview one, fill it in with from_starter and paths, then add dry_run. Brussle returns the definition and its cost, and creates nothing:
  • definition is exactly what a create makes. To change its question, criteria or recipe, edit it and create it as an ordinary definition.
  • cost_per_answer is the mean number of rows per answer (size class times the engine’s multiple), given in standard evaluations on Jev, two rows kept each, on a sample of up to 1,000 of the documents the judgment would judge. On jev (multiple 2) it is 1.0 when each answer is standard and 4.0 when each is large. On gpt-6-luna (multiple 5) the same answers give 2.5 and 10.
  • estimate is the cost to backfill the documents you have. A create never starts a backfill.
  • replay, for a starter that reads related documents, is its estimated monthly cost. See the replay estimate.
The same body without dry_run creates the judgment, and a starter that reads related documents also needs confirm: true. Give each placeholder that is not optional, with the right kind of path, or Brussle refuses the request with invalid_request and details names the problem. Beside from_starter and paths, you can send only name, engine, freshness, activate, confirm and dry_run. A starter sets no freshness policy, so without freshness the judgment is on_read, and you cannot filter, sort or subscribe on its answers. Send "freshness": {"policy": "on_change"}, as the bodies in starter judgments do. A starter can suggest how Brussle reads its outcomes, with implicit negatives and an outcome rule on a path you give. Brussle sets them when it first creates the judgment (implicit negatives on each plan, the rule only on a plan with outcome rules). On other plans, outcomes returns the rule with plan_required, and you can set it with PATCH after you upgrade. The dashboard’s New judgment has the same flow: pick a starter, choose each path from your documents’ fields, check the cost, and create.

When you leave out context

Brussle refuses a create without context with invalid_request and creates nothing, but details.suggested_context suggests a recipe from a sample of up to 100 of your documents:
  • It keeps short text, numbers, booleans and small attributes, and the most recent 5 items of a long array.
  • It leaves out ids, timestamps, links, values that look binary, fields that are rarely present, and fields past the first 24. excluded gives the reason for each.
  • A very long value gets a max_chars when the standard size class has room for it beside everything else kept, and otherwise is left out as long.
  • Images: each name in the documents’ images is one candidate, images.<name>. On an engine that reads no images, the suggestion leaves each out as image. On one that does, they stay only while the context stays standard, the last one leaving first, and a full-size photo does not fit.
  • max_tokens keeps the context and its question in the standard size class, at most 2,000 tokens less the question’s.
The same documents always give the same suggestion. A longer question that you add later also counts, so if cost_per_answer rises above a standard answer’s (1.0 on jev, 2.5 on gpt-6-luna), lower max_tokens by about the increase in the question, or shorten the question. Then do one of these:
  • Send your own recipe as context, starting from the suggestion.
  • Send "use_context": "suggested" to create the judgment with the suggestion unchanged. The response’s definition shows the recipe it used.
  • Send "use_context": "whole_state" to send the whole state, up to the engine’s limit, and no images. You rarely want this, since it costs the most per answer and every change to the document judges it again (the response warns you).
A namespace with no documents yet has nothing to suggest from, so suggested_context is null. Send a recipe or whole_state.

Context size is the cost

Each answer counts as its size class times the multiple of its engine. The tokens of the compiled context and the question together decide the size class:
  • The question counts as the engine reads it, with its criteria and the description of each option. A choice among many long options can be large where a bool question over the same context is standard.
  • Each engine counts tokens its own way, so the same context can be in a smaller class on one engine than on another. An engine that reads images counts each image by its size, while another counts only its digest.
  • An answer costs its size class again each time the document changes. Take 10M documents that each change 10 times a month. At 2,000 tokens they are 100M standard rows, which count as 200M on Jev. At 6,000 tokens each answer is large, so they count as 800M.
  • A smaller context lowers the bill only when it moves answers into a smaller class. The last three messages in place of a 6,000-token history make each answer standard, at a quarter of the price. A cut from 1,500 to 800 tokens changes nothing.
Pricing has the price per row kept, which falls as your organization’s volume in a billing period grows.

Let your outcomes tune the recipe

Most recipes start large, because it is hard to know in advance which fields a question needs. Brussle tests smaller versions of the recipe on the contexts already stored with your labelled answers once a version’s correction rests on 100 outcomes (20 of each kind), then at most once every 30 days. It suggests one only when it moves answers into a smaller size class and does no worse on your outcomes beyond noise. no_worse lists the smaller recipes that did no worse, even when none is cheaper. Tuning is on Team and Scale, is never billed, and never applies a suggestion for you.
The suggestion’s definition is your active version with only context changed, so your thresholds stay. Post it as a new version, activate it, and confirm its shadow report. Find a cheaper recipe describes every field. To score a recipe that reads more, name it as an alternative, which Brussle bills as judging after you confirm its quote.

Share recipes where you can

Judgments that read the same compiled context go to the engine together, up to 32 questions in one request. Sharing a request makes them faster, lighter on the rate limits and cheaper, since each question after the first costs from a quarter of a row (see questions in one request). Before you give a new judgment its own recipe, check whether one you have is enough.

Check what the engine saw

Each evaluation stores its compiled context, so you can get the document with its history and contexts (or open it in the dashboard) to see the exact text and the reference to each image that the engine received. Over HTTP, add include=history,context to the get. The SDKs take one flag for each part:
  • context_tokens and context_truncated show how near a recipe is to its maximum.
  • relations_capped shows that a relation stopped before it checked every matching document.
  • Each image is at its image path, such as images.photo, as its reference or as a mark that the engine did not read it. Get the image with GET /namespaces/{ns}/images/{digest}.

Fit the engine you pin

Every active engine takes up to 32,000 tokens for the context plus the longest question. Each engine’s page gives its limits, including how many images it reads (see limits). A recipe reads an image only where it names one as images.<name>, which it can do in fields, in previous.fields, and in a relation’s fields and latest. An engine that reads images counts each one toward the context by its size. An engine that does not gets each image’s digest instead, and the create warns you. See judge the images in a document.