grounding checks that identifying values in a call's arguments appear in what the person wrote, in what a tool returned, or in values you marked as known. A value the model invented gets a guide ("ask the person, or look it up") instead of a call.
guards.grounding({ args: { refund_invoice: ["invoice_id", "amount"] }, minLength: 3 });Options#
Which values are checked#
Without args, the guard walks the arguments at any depth and checks a string or number when:
- its key is id, ends in _id or _ids, ends in Id or Ids after a lowercase letter, or contains email, phone, amount, account, number or iban (any case), or
- it is a string shaped like an email address, or like a phone number with at least 7 digits, whatever its key.
Where a value may come from#
- The transcript. Text in messages with role user or tool. What the assistant itself said does not count.
- Grounded values. Values you add with run.ground(...) (an account id you looked up), plus the run's requester and run.identify(...) values. These live on the run object, not in the store, so add them again on each request.
Matching is case-insensitive and on whole tokens: INV-100 is not found in INV-1001, and 100 is not found in 100.99. A number also matches its two-decimal form (90.00) and its US thousands form (1,200).
The transcript has to reach the guard#
| Integration | Passes the conversation |
|---|---|
| Vercel AI SDK (run.tools, run.toolApproval) | Yes, from the SDK |
| RubyLLM (run.ruby_llm(tool, chat:)) | Yes, from chat.messages when you pass chat: |
| run.check(tool, args, { messages }) | When you pass messages |
| Python run.wrap(tool, messages=...) | When you pass messages (a list or a function that returns one) |
| TypeScript run.wrap, Ruby run.wrap | No |
Messages can be dicts or hashes with role and content, or objects with those attributes. Content can be a string or nested parts; every string in it is read.
Without a transcript and without grounded values, the guard has nothing to compare against and answers proceed with reason no_transcript. With requireTranscript: true (TypeScript), it answers deny with reason no_transcript instead. In monitor mode that refusal reaches onAlert, which is a way to find integrations that do not pass the conversation.
Decision#
{ "kind": "guide", "reason": "ungrounded", "message": "Don't guess invoice_id: \"INV-77\" isn't from the person or a tool result. Ask the person, or look it up with a tool." }The guard stops at the first value it cannot trace.