Skip to main content
Set how long a reply waits for the stores a search asks, and what happens to a store that answers after the reply. A streaming chat shows each store’s cards as they arrive and streams the few that come after the reply. A texting app sends the reply once, as its last word.
agentcard.ts
Agentcard writes the reply once every store answered, or once storeWaitMs passed, whichever comes first. Leave both options out and Agentcard chooses the wait. Agentcard ends every store search at 30 seconds, so a storeWaitMs above 30000 waits no longer than 30000 does.

Show late cards in a streaming chat

A chat that shows cards as they come uses storeWaitMs: 25000 and lateResults: 'stream'. Each store’s cards show the moment that store answers, so the shopper sees products long before the reply. The reply waits up to 25 seconds, and 99.7% of stores show their first products within that wait. A store that answers later sends its cards in the same turn, after the reply, with one message that says what they added:
The late cards reach the same callbacks as the first ones: sendLink, onProducts, or onItem. Keep each callback ready to add a card below the reply, not only above it. The turn’s onResult lists the late cards in result.products, after the answer’s own, so a cart panel or a list of products built from onResult shows them too.

Hold late cards in a texting app

A texting app that cannot add a card after it sent the reply uses storeWaitMs: 20000 and lateResults: 'hold':
sms.ts
The shopper waits up to 20 seconds for the reply, and the reply is the turn’s last message. 96% of stores show their first products within that wait. A store that answers after the reply sends nothing in that turn, so about 4 stores in 100 miss the reply. A longer wait catches more of them, up to the 30-second limit, and the shopper waits that much longer.

Set a wait for one turn

Pass the same options to buy.turn to change them for one message. An option the turn leaves out keeps the tool’s:
chat.ts
An app that calls client.buy itself sends the fields store_wait_ms and late_results on the request. A storeWaitMs that is not a whole number of milliseconds, 0 or more, or a lateResults other than stream or hold, throws a TypeError before any call, so a typo never reaches a shopper. buyTool({ agentcard, externalUserId: shopper.id, storeWaitMs: '25s' }) throws:
Pass the wait as a number of milliseconds instead:
agentcard.ts