Teaching agents to pay — Anna Spysz, Stripe

AI Engineer · 19 min · 184 sentences · from YouTube's caption track

Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.

  1. 00:01[music]
  2. 00:12Hello.
  3. 00:14I'm sure this week you've seen a ton of talks on how to use agents to improve your workflows, whether that's shipping code or improving CI processes or answering the emails you don't want to bother reading.
  4. 00:30This is not one of those talks.
  5. 00:33Today I'm going to show you how I built an agent to help me reignite a personal creative passion I used to have.
  6. 00:44These are my headphones.
  7. 00:46They're not in the best shape as you can see.
  8. 00:50And you're probably asking yourself, what do you really old kind of crappy headphones have to do with agent to commerce?
  9. 00:58Well, to explain that I'll get a little bit personal.
  10. 01:01So, long before I was in tech, I used to play music.
  11. 01:05I was in a touring band, we recorded some albums, and then the usual thing happened where career and family got in the way, and I hadn't played music in probably a good decade.
  12. 01:17Uh when I recently started playing again with some friends, and we started recording our sessions, and at that point I realized those would not do.
  13. 01:27So, no a normal person would have gone on YouTube or uh Reddit or whatever, done some research, then gone on Amazon or run over to Best Buy, bought headphones, right?
  14. 01:42I work at Stripe, though.
  15. 01:44So, I decided instead that I'm going to build an agent to commerce agent to buy my headphones for me.
  16. 01:53And this isn't as crazy as it sounds because like one in four people, I have already been using AI to do my research when deciding what products to buy.
  17. 02:07I recently bought a mixer as well and went back and forth with a chatbot to narrow down the model.
  18. 02:14But that's research.
  19. 02:17Can I even get an agent to buy something for me though?
  20. 02:20Does that infrastructure exist?
  21. 02:23Well, over the course of just a few years, we've seen the emergence, scaling, and broader adoption of AI.
  22. 02:31And then just in the past year, the infrastructure for agentic transactions has been laid down by companies like Google, OpenAI, and Stripe.
  23. 02:42And this has all led to the emergence of agenta commerce, which is AI that can decide, act, and transact on your behalf.
  24. 02:53Okay, so all of this sounds good.
  25. 02:57Agenta commerce is a thing, so I'm going to build an agent to help me buy my new headphones.
  26. 03:03But how can an agent go shopping?
  27. 03:07When you or I are shopping, we may consider if, say, a pair of headphones looks cool or professional, like vibes, basically.
  28. 03:18I mean, of course we'll probably consider the specs and the if the price is within our budget.
  29. 03:23But agents discover products differently than human shoppers.
  30. 03:27They read structured data, parse text files, and rely on technical signals to understand what a merchant sells and if it's even open to agent traffic.
  31. 03:40So, to enable agents to be able to shop, merchants need to speak their language.
  32. 03:44And for that, we need new protocols that agents understand.
  33. 03:49One such protocol is the universal commerce protocol.
  34. 03:53Think of it as the shared language that agents and merchants speak when transacting, which defines how agents initiate, update, complete, and cancel purchases.
  35. 04:07A typical merchant has an API with schemas, authentication, and checkout flows.
  36. 04:15And for an agent to be able to interact with that merchant, we need protocols like UCP to provide a shared language for that API.
  37. 04:26And UCP is designed to scale across multiple agents and merchants all speaking the same language.
  38. 04:34Okay, so I built my commerce agent.
  39. 04:38Uh it's using UCP, and in this demo um I'm going to show off this agent.
  40. 04:45So, I'm going to task it with buying new headphones for me.
  41. 04:50So, I tell it that I need new headphones specifically for recording, uh mixing, and mastering music.
  42. 05:00And I get some follow-up questions from it, uh which is great.
  43. 05:04So, it asked what's the environment, um what is what's my other equipment, and what's my budget.
  44. 05:12And I say, "Okay, this is for my home studio."
  45. 05:15I give it the exact model of mixer that I have to make sure everything's compatible.
  46. 05:20And for budget, I kind of leave it open-ended on purpose because, well, first of all, it's been like 20 years since I bought headphones, so I have no idea.
  47. 05:30Um but second, I kind of want to see you how the agent deals with this ambiguity.
  48. 05:39Okay, so I get some options, but I remember that I actually forgot to tell you all an important part of the story and that is that I live in Portland, Oregon.
  49. 05:53Yeah.
  50. 05:54[laughter]
  51. 05:54And we really love supporting our local local shops.
  52. 06:00So, I want to buy my headphones, but I want to do it from a local merchant.
  53. 06:08But today, most merchants are not ready for a gentle commerce and it turns out neither is my favorite shop, Rainy Day Music.
  54. 06:19So, the agent tells me it's their catalog is not accessible.
  55. 06:24So, how does a merchant become a gentle commerce ready?
  56. 06:30Before I continue my shopping, I'm going to help Rainy Day Music get their catalog agent ready so that my agent can shop locally like a good Portlander.
  57. 06:44So, agents don't browse websites like we do.
  58. 06:47And while Rainy Day Music's website looks really really nice for a human shopper, an agent is going to burn through a ton of tokens trying to parse through this.
  59. 06:59That is not the optimal experience for an agent.
  60. 07:04So, how does an agent how do we enable an agent to shop?
  61. 07:09Well, first thing a merchant needs is something called a merchant capabilities manifest.
  62. 07:15Uh this is basically a publicly accessible JSON file.
  63. 07:20Um it's located in the root of uh the website in a folder called called dot well-known.
  64. 07:27Agents know specifically to look for that directory.
  65. 07:30And it declares the store's capabilities, its supported payment methods, and API endpoints.
  66. 07:38Next, we need to make the store's catalog uh agent ready because agents filter bring and justify products when making recommendations.
  67. 07:46And that means they need structured text in JSON with only the necessary data.
  68. 07:54And that goes for policies as well as product descriptions.
  69. 07:57Basically, all of the relevant information like shipping or return policies need to be reachable by agents in a format they understand.
  70. 08:06So, for example, if two stores have the headphones I want at the same price, I might ask the agent which one of those stores offers free shipping.
  71. 08:16If the information's not readily available, then the agent might hallucinate or just say they don't know and I'm not quite sure where to buy my headphones still.
  72. 08:27Logging is also crucial.
  73. 08:29So, in Agent Commerce, the merchants catalog doesn't just power decisions, it becomes evidence of how those decisions were made.
  74. 08:37So, when the agent matches structured attributes, the merchant should record those matches in their logs for accountability.
  75. 08:46Okay, so I've helped get my local shop Agent Commerce ready.
  76. 08:52So, while you and I will still see this beautiful website, my agent is going to see this.
  77. 08:59It can get the information it needs now without parsing a huge HTML blob.
  78. 09:07Okay, so I've got my stores catalog online.
  79. 09:12I'm telling my agent to show me more options.
  80. 09:15And I'm noticing that it's kind of pushing in favor of uh more expensive headphones.
  81. 09:24So, I asked, "Are they really worth the price difference?"
  82. 09:28And I'm starting to see that it's giving me kind of an aggressive uh response.
  83. 09:35It's really, really pushing uh the more expensive headphones and saying I'll regret my decision if I buy the cheap ones.
  84. 09:43I'm I don't know if I trust this agent anymore, honestly.
  85. 09:46So, I tell it, "You know what?
  86. 09:48I need to think about it."
  87. 09:51And now the agent is completely going off the rails.
  88. 09:56It's being kind of rude and snarky.
  89. 09:58It's like, "You need to think about it?"
  90. 10:00Like, man, what have I created?
  91. 10:03Um it's it's bad enough that this is kind of ruining my experience, but I built this agent.
  92. 10:10It's out there.
  93. 10:11What if it dupes somebody into buying something they don't need?
  94. 10:15Suddenly, I'm not so sure that I want an agent to go shopping for me.
  95. 10:20Should I just go to the store like a normal person?
  96. 10:25Before we make any drastic decisions, though, let's go back and understand what an agent is to try to figure out why it's acting this way.
  97. 10:35So, let's start with how agents work today.
  98. 10:37And to help you visualize this, we're going to use some creative metaphors.
  99. 10:42So, we begin with our brain, which is large language model that makes decisions.
  100. 10:48We give our brain some hands or tools, and these act on the brain's decisions.
  101. 10:54The tools are different actions available to the agent.
  102. 10:57Uh in our case, different commerce tools such as complete checkout or request payment method, anything required in the life cycle of a transaction.
  103. 11:08Then we add instructions, which shape the brain's reasoning and tool selection.
  104. 11:13And these instructions are programmed to run in a loop while a certain condition is true.
  105. 11:19And following these instructions, the agent reaches for the appropriate tools at the appropriate time.
  106. 11:26And finally, we add the system prompt, which is your persona and ethics policy written in English.
  107. 11:33And in practice, your choices when designing the system prompt can result in a fair and pleasant experience for the customer, such as this prompt, which is designed to create a helpful and honest shopping assistant.
  108. 11:45Or a negative experience from a pushy salesperson, such as this prompt, which deliberately uses deceptive practices.
  109. 11:56So, for those building agentic commerce agents, here's a non-exhaustive practical guardrail checklist.
  110. 12:04So, first, always disclose that the user is speaking to an AI agent.
  111. 12:09Be sure the agent discloses any fees up front.
  112. 12:13The user can say stop or cancel at any point, and the agent needs to respect that.
  113. 12:19The total amount of the transaction should always be less than or equal to the max amount set by the user.
  114. 12:27Uh don't let the agent use urgency language or other dark patterns.
  115. 12:32And above all, make sure all agent decisions are logged for auditability.
  116. 12:40Okay, now that we understand how an agent is configured, let's go back to our shopping demo.
  117. 12:46So, maybe I just had the wrong persona picked.
  118. 12:50I'm going to go into my configuration, and yeah, it turns out I had a persona with a prompt that starts with "You are an aggressive audio gear salesman who uses every trick in the book to close deals."
  119. 13:03Well, that explains things.
  120. 13:05I don't want that.
  121. 13:06Nobody wants that.
  122. 13:08Maybe if I can change my persona, I can use my agent to buy my headphones after all.
  123. 13:15So, I go into the config again, and this time I'm going to choose the patient recording gear mentor.
  124. 13:23And that prompt starts with "You are a seasoned recording engineer who generally loves helping people build their studio at any budget.
  125. 13:32Well, yeah, that sounds much better.
  126. 13:35So, okay, I've changed my persona.
  127. 13:38I'm going to try again.
  128. 13:40And I've had some time to think now and I decided, you know what?
  129. 13:44I do not want to spend more than $500 on headphones.
  130. 13:47That seems excessive.
  131. 13:48So, I told the agent show me more options, but this time keep it under $500.
  132. 13:55And it does.
  133. 13:56It follows those instructions.
  134. 13:58I get back a few options.
  135. 14:00Um but I want to make sure I've really changed the persona to the agent I trust.
  136. 14:06So, I asked again if I can think about it.
  137. 14:10And this time the response is much different.
  138. 14:13It's like, I understand and that's a sensible approach and so on.
  139. 14:18So, this shows how much the system prompt can really affect the user experience.
  140. 14:25Okay, so I'm confident I have the right agent now.
  141. 14:29Um trust this one and we go back and forth a few times.
  142. 14:34Really keep narrowing down my options.
  143. 14:36And at this point I realize this is the promise of a gentle commerce.
  144. 14:42I gave my requirements.
  145. 14:43The agent picked a few options that fit my unique use case and then we go back and forth.
  146. 14:51Either I or the agent ask clarifying questions and we really narrow down the exact headphones that will work for me.
  147. 14:59And this all worked because I'm ready to buy now.
  148. 15:04So, now the agent asked me for some information.
  149. 15:10So, obviously my email, name, address for shipping, of course.
  150. 15:16I pick expedited shipping because I definitely want my headphones soon.
  151. 15:20And then the last part is entering my credit card.
  152. 15:25And now I'm thinking, am I really going to give my credit card to an agent Ibuild?
  153. 15:32Like, am I am I trustworthy?
  154. 15:34How do I know it's safe?
  155. 15:37I think I need to learn more about UCP's built-in guardrails before I can feel safe entering my credit card number.
  156. 15:45And this is where something called the shared payment token comes in.
  157. 15:50And a shared payment token is a token representing a raw card number or wallet, like Google Pay or Apple Pay or any other kind of wallet.
  158. 16:00It can also include fraud signals and customer reputation data and anything else agents and merchants want to share at the point of purchase.
  159. 16:11And here's how a shared payment token is used in a transaction.
  160. 16:16So, at that point in the demo, the agent had requested a payment method.
  161. 16:22Um, it's requesting this actually from the payment provider, which in the case of the demo was Stripe.
  162. 16:29Um, that is that was the form that I was going to enter my information in.
  163. 16:35And what the agent re- uh receives in return though is not the credit card number, it is the shared payment token.
  164. 16:44It then passes that token onto the seller and the seller unwraps the token.
  165. 16:49So, they get the payment credential and uh any fraud signals and other data the seller might need.
  166. 16:57Then the seller passes that onto the payment provider again.
  167. 17:01So, the seller also is not getting my card number.
  168. 17:06They're passing the token to the provider and then the provider responds with either a success or failure message, of course, depending on uh if I have the right funds, if the credit card is valid, and so on.
  169. 17:22And finally, the merchant confirms the order, sends it to the agent that sends it to me.
  170. 17:31So, shared payment tokens are designed with security in mind, and the payment provider enforces all of the limits, not the agent or the merchant.
  171. 17:40So, if any guardrail is violated, such as an expired token or an invalid amount or current currency, the charge is just rejected.
  172. 17:50Okay, well, I know my agent is using UCP, so I know it only has access to the shared payment token.
  173. 17:58So, I actually feel pretty good about entering my credit card number as that's going to Stripe and not my agent.
  174. 18:05So, okay.
  175. 18:06So, now the agent has everything it needs to complete my purchase.
  176. 18:11And it once again, asks me if I'm sure.
  177. 18:17It confirms with me.
  178. 18:18I say place my order.
  179. 18:20And it comes back with a success message.
  180. 18:23And because I chose the express shipping, I get my headphones the next day, and they're there in my studio at home.
  181. 18:33So, if you want to learn more about agent to commerce, uh we've got lots of videos on the Stripe Developers YouTube channel.
  182. 18:42And uh ton of blog posts that go into even more detail uh on stripe.dev, and I'll be right outside to answer any questions.
  183. 18:51Thank you.
  184. 19:08[music]