Host tools read. They never write, and what they return never authorizes anything. Results ground answers exactly like page-reported account facts.
Release preview: host read tools are implemented and tested in the repository and reach the hosted script with its next release. The@puntego/reacthook below (usePuntegoTool) is not yet published to npm. Feature-detect withtypeof window.Puntego?.registerTool === 'function'.
Register a tool
A page offers at most 8 tools at once.
registerTool returns false and logs
why in the console when a definition is refused; unregisterTool(name) removes
one. Tools belong to the page: setIdentity() keeps them, destroy() clears
them like every other registration.
What happens on a turn
- On a question the visitor asked, the page offers the guide its tools (names, descriptions and parameters; never your code).
- When the answer needs data only a tool returns, the guide asks the page to run up to 2 calls, with arguments of the types you declared. The card says “Looking up your account…” meanwhile.
- Your handlers run in the visitor’s browser session, with your own API’s
permissions. The page checks the arguments against your declaration first,
then keeps only the listed
fieldsof the result. - The same turn is sent again with the results and answered. That request offers no tools, so there is one round at most.
Limits and privacy
What a tool returns is plain JSON data. Before anything leaves the page:- only the listed
fieldsstay (of the object you return, or of each object in an array you return), whatever kind of object it is: a class instance or an SDK model keeps only its listed fields too, and an unlisted field is never read; - keys named like a credential or a direct identifier are dropped, and a value that contains an email address, phone number, card number, IBAN, national ID or a signed token (a JWT) is dropped whole, at any depth;
- text is kept on one line and up to 400 characters, arrays up to 25 items, objects up to 32 keys, 4 levels deep, and 8 KB per result (16 KB for all results of a turn);
- an exception, a rejected promise, a timeout or data that is not JSON becomes a
status (
error,timeout,invalid_result,too_large), never an error message sent to the model.
Signed results
A result grounds the answer as the page’s word. When a tool reads facts the guide may state as verified (plan, seats, entitlements), return a token your server signed instead of raw data:Observe tool calls
Each call reportstool:result with the tool’s name, its status, how long it
took and the turn — never its arguments or data:
Troubleshooting
- The guide never calls the tool. The question must need data the page,
the account facts and the conversation do not already give. Make the
descriptionsay exactly what the tool reads. registerToolreturnsfalse. The console names the rule: the name pattern, a missingfieldslist, a field named like personal data, or the 8-tool limit.- The answer says the data could not be read. The tool returned a status
other than
ok; listen totool:resultto see which.