one sec, checking target for la croix.
React with a đ
PassonReaction to buy.turn. Show the emoji as a tapback on the shopperâs bubble.
chat.ts
- A message that starts a search gets it the moment
buy.turnopens, before your model runs. - A call that Agentcard has not answered within 1 second puts the đ on a message that has none yet: a slow
yes, a pick, or a confirm that is still placing the order. The tool sends no text with the đ.
yes, 2, or a code, a step toward checkout such as ok lets checkout, and an acknowledgement such as its ok.
When the đ went out, the model reads shopper_already_told_looking: true in that turnâs answers, and its description tells it not to acknowledge the request again. The reply opens with the answer or the question, not on it. The field reads false on a turn that reacted with nothing, and when onReaction threw. An onReaction that throws costs only the reaction.
With onItem on the turn, the đ still goes to onReaction and never joins the turnâs items, because it sits on the shopperâs bubble and not in the agentâs sequence.
Send a short text instead
For SMS, or any chat that shows no reactions, passonWorking and no onReaction, or set ack: 'text':
chat.ts
ack takes 'reaction', 'text', or 'none'. Left out, the tool reacts when the tool or the turn has an onReaction, and sends text through onWorking otherwise. With both callbacks, the shopper gets the đ and never the text too. 'none', or false, sends nothing.
With ack: 'reaction', or an onReaction on the turn, Agentcardâs line never reaches the shopper as text, not even through onText. The shopper reads the đ alone.
A streamed search that buy.turn sends straight to Agentcard gets a line that Agentcard writes while it searches, from the shopperâs message and the last turns of the conversation. After a search for office chairs, can you show me yellow ones reads looking now for yellow ergonomic office chairs under $250. The line goes to onWorking, or to onText when you pass no onWorking, before the cards.
The line goes out only while the shopper has read nothing else of the turn, because a line after a card or a message says nothing. When it goes out, the model reads shopper_already_told_looking: true.
When your app writes the modelâs words through the turn, a straight search has a fallback. If Agentcardâs line has not come after twice ackDelayMs, 2 seconds by default, and the call has not answered, the tool sends one moment once through onWorking. A line of Agentcardâs that comes after that is dropped, so the shopper reads one line. A call that answers or fails first cancels the fallback, so a failed search is never followed by one moment.
A pick, a confirm, or an answer such as yes or an address waits for the delay. When the turn has shown the shopper nothing for ackDelayMs, 1 second by default, it sends one line through onWorking. A turn sends one line at most, however many calls the model makes. The call waits for onWorking, so the shopper reads the line before any link and before the model answers. An onWorking that throws costs only the line.
A fixed line names nothing the shopper said. A turn counts what the shopper read only when your app writes the modelâs words through the turn, with
onItem, onMessage, turn.messageStream(), or turn.say(). In any other app, the tool sends the fixed line when a call has gone ackDelayMs without an answer.
Read which searches get Agentcardâs line
On a tool built withdirect: true, buy.turn asks Agentcard for the line on a search it sends without your model. A pick, a confirm, an address, and an answer such as yes get no line from Agentcard.
A search sent with stream: false gets none either, because a caller that waits for the whole answer would read the line after the answer.
A turn that your model runs gets no line from Agentcard. The toolâs description tells your model to write one short line itself before it calls the tool on a new request, and that line is the turnâs acknowledgement. When your app writes the modelâs words through the turn and the model has written nothing, the tool sends a fixed line instead: one moment for a search, once the model calls the tool or twice ackDelayMs passes. When the shopper already read a line, the call asks Agentcard for none.
With stream: false, the tool writes the searchâs line itself. The words rotate through six templates, and one tool never sends the same template twice in a row. A short paraphrase of the request goes in when the tool can read one. It stops before any link, email address, phone number, street address, or long number, and a request that starts with one gets a reply that names nothing, such as looking for that now.
Pass ack: (ask) => text to write your own text from the shopperâs words, where an empty answer sends none. Pass ackDelayMs to change the 1 second for either mode.
Drop your modelâs opening line
When your modelâs first message of a turn is a line likeon it, looking for a dryer under $20, written before it calls the tool, and the fixed line already reached the shopper, the shopper would read two. The turn keeps the modelâs line in the modelâs own history and never sends it. A line counts as an opening line when it is one line of at most 90 characters, says the turn is working, as on it, looking for does, asks nothing, and claims no result such as a price or a cart. A first message that asks a question, answers, or says what a search found goes out, and so does every message after it.
When the app failed to send the fixed line, the modelâs line goes out in its place, so the shopper reads one line either way.
End the turn when your model fails
If your modelâs run fails before it writes or calls anything, the turn would still sendone moment or a đ after your app showed its error. Call turn.end() in the catch or finally of the run:
chat.ts
turn.end() cancels the wait line the turn holds and the acknowledgement of every call still running, a đ or a line for a slow pick, confirm, or answer. A call still running keeps answering: its text, its products and its links reach the shopper after your error message, and a search that streams sends Agentcardâs line for it. A second call of turn.end() does nothing, so a finally is safe too.
Acknowledge before the model runs
The model takes several seconds to call the tool after the shopperâs message arrives. Withbuy.turn, the turn acknowledges the moment it opens. In reaction mode, it calls instantReaction for you and puts the đ on the message. In text mode, a streamed search waits for Agentcardâs line, so the turn calls instantAck for you only with stream: false or an ack function.
Outside a turn, call buy.instantReaction(message) the moment the message arrives, before your model runs, and put the emoji it returns on the message. In text mode, call buy.instantAck(message) and send the text it returns.
chat.ts
hi, a message that carries the shopperâs own details, or a short reply right after a question the last answer asked. A reply that opens a new request, such as find me black running shoes, or that runs past four words is still a search. When either returns an acknowledgement, neither the tool nor Agentcard sends one for that turn.
The reply never reads the shopperâs details back, and it names the request only when it reads as a short, whole phrase. Otherwise it says on it, give me a moment or another reply that names nothing. Pass ack: 'none' to the tool when you acknowledge yourself.
Show a long wait
A turn that runs long, even past a minute, gets no second text line. A search often takes 10 to 40 seconds, so a second line at any wait short enough to help would land on most searches and bring back the chatter the reaction replaces. To show a long wait, passonProgress and show its stage as a status line or a typing indicator:
chat.ts
stream: false to wait for each whole answer instead.
Check it in the sandbox
- Send âtwo packs of AA batteries from Amazonâ as a test shopper. Check that the đ appears on your message at once, before the model answers, and that the reply opens with the answer.
- Send âyesâ after a cart. Check that no đ appears at once, and that a slow answer gets one after about 1 second.
- Send âthe first oneâ after a product list. Check that no reaction or text appears when the turn opens.
- Switch to
ack: 'text'and sendla croix from target. Check that a line likeone sec, checking target for la croixreachesonWorkingbefore the cards, and that the reply opens with the answer. - Send âthe first oneâ after a product list, in text mode, with a store slow enough to pass 1 second. Check that
got it, one momentarrives once and repeats none of your words. - Make
onReactionthrow. Check that the turn still answers and the model readsshopper_already_told_looking: false. - Make your model throw before it writes anything, and call
turn.end()in thecatch. Wait 3 seconds. Check that the shopper reads your error and noone momentafter it.