Best practices¶
Lessons measured on real requests. Most mistakes come from how a schema asks, not from the API.
Design the schema¶
- One fact per field. Split "name and ID" into two fields.
- Use the most specific type.
enuminstead of free text for categories,boolfor yes/no,numberwithinteger: truefor amounts. - Use
extract: truefor anything copied from the input: names, IDs, reference numbers. It makes invented or re-spelled values impossible. - Use
enumfor values you pass on (for example to a URL). Anextractfield asked for "the asset the user means" returned the whole sentence, which is a valid part of the text. - Size numbers for their range.
max_digitscounts every character; money usually needs 10–12.
Write instructions¶
- Say what the value is, name the traps (subtotal vs total, PB1 is a
tax), and define when it is
null. - Give an example for odd formats: "(56rb = 56000)".
- Put shared rules in
system. - For decisions, define each option in the instruction. Without definitions, a model chose "reject" for a case the policy said to review, confidently and unanimously.
Let code do what code does best¶
| Task | Do | Avoid |
|---|---|---|
| Arithmetic | compute fields |
asking the model to calculate |
| Consistency | *_expr rules |
asking the model "is the total correct?" |
| Formats and lengths | len_*, match rules |
asking the model to count |
| Status, balances, approvals | tool calls to the system of record | reading them from the conversation |
| Formatting big numbers | your own code | "write with thousands separators" (1514071277 became "Rp15.140.712.77") |
Rules and stages¶
- Put gates after the data you want to keep: a
rejectcancels its own stage. - Hide gate values from later prompts with a final
{"do": "drop"}. - Send low confidence straight to
review; areturnmakes the model repeat its answer with more confidence. - For data an answer depends on (a price, a balance), use
on_error: "reject"on the call and an honeston_rejecton the answer. Withreviewonly, a failed call led to an invented price.
Trust, but verify¶
- Treat
needs_reviewas part of your workflow, not as an error. - Pick
review_thresholdfrom an evaluation, and remember that confidence does not catch confident mistakes. - Store
provenancewith each result you act on. - In regulated decisions (credit, claims), use the result as a recommendation for a person.
Limits to plan for¶
- One request is processed at a time per deployment; set client timeouts in
minutes and avoid very large
max_new_tokensunless needed. max_new_tokensis per field (1–512). A cut-off typed value becomesnull; a cut-off text is returned as far as it got.- Enums: up to 24 values. Lists: simple values only.
- Very long documents are limited by the model's context length.
- Image input needs a vision model on the deployment.