Teaching agents to pay — Anna Spysz, Stripe https://www.youtube.com/watch?v=A-zeQiYkmXk AI Engineer · 19 min · 184 sentences · sentence-level transcript from YouTube's caption track; each line begins at the time shown [00:01] [music] [00:12] Hello. [00:14] I'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. [00:30] This is not one of those talks. [00:33] Today I'm going to show you how I built an agent to help me reignite a personal creative passion I used to have. [00:44] These are my headphones. [00:46] They're not in the best shape as you can see. [00:50] And you're probably asking yourself, what do you really old kind of crappy headphones have to do with agent to commerce? [00:58] Well, to explain that I'll get a little bit personal. [01:01] So, long before I was in tech, I used to play music. [01:05] I 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. [01:17] Uh 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. [01:27] So, 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? [01:42] I work at Stripe, though. [01:44] So, I decided instead that I'm going to build an agent to commerce agent to buy my headphones for me. [01:53] And 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. [02:07] I recently bought a mixer as well and went back and forth with a chatbot to narrow down the model. [02:14] But that's research. [02:17] Can I even get an agent to buy something for me though? [02:20] Does that infrastructure exist? [02:23] Well, over the course of just a few years, we've seen the emergence, scaling, and broader adoption of AI. [02:31] And then just in the past year, the infrastructure for agentic transactions has been laid down by companies like Google, OpenAI, and Stripe. [02:42] And this has all led to the emergence of agenta commerce, which is AI that can decide, act, and transact on your behalf. [02:53] Okay, so all of this sounds good. [02:57] Agenta commerce is a thing, so I'm going to build an agent to help me buy my new headphones. [03:03] But how can an agent go shopping? [03:07] When you or I are shopping, we may consider if, say, a pair of headphones looks cool or professional, like vibes, basically. [03:18] I mean, of course we'll probably consider the specs and the if the price is within our budget. [03:23] But agents discover products differently than human shoppers. [03:27] They 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. [03:40] So, to enable agents to be able to shop, merchants need to speak their language. [03:44] And for that, we need new protocols that agents understand. [03:49] One such protocol is the universal commerce protocol. [03:53] Think of it as the shared language that agents and merchants speak when transacting, which defines how agents initiate, update, complete, and cancel purchases. [04:07] A typical merchant has an API with schemas, authentication, and checkout flows. [04:15] And for an agent to be able to interact with that merchant, we need protocols like UCP to provide a shared language for that API. [04:26] And UCP is designed to scale across multiple agents and merchants all speaking the same language. [04:34] Okay, so I built my commerce agent. [04:38] Uh it's using UCP, and in this demo um I'm going to show off this agent. [04:45] So, I'm going to task it with buying new headphones for me. [04:50] So, I tell it that I need new headphones specifically for recording, uh mixing, and mastering music. [05:00] And I get some follow-up questions from it, uh which is great. [05:04] So, it asked what's the environment, um what is what's my other equipment, and what's my budget. [05:12] And I say, "Okay, this is for my home studio." [05:15] I give it the exact model of mixer that I have to make sure everything's compatible. [05:20] And 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. [05:30] Um but second, I kind of want to see you how the agent deals with this ambiguity. [05:39] Okay, 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. [05:53] Yeah. [05:54] [laughter] [05:54] And we really love supporting our local local shops. [06:00] So, I want to buy my headphones, but I want to do it from a local merchant. [06:08] But today, most merchants are not ready for a gentle commerce and it turns out neither is my favorite shop, Rainy Day Music. [06:19] So, the agent tells me it's their catalog is not accessible. [06:24] So, how does a merchant become a gentle commerce ready? [06:30] Before 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. [06:44] So, agents don't browse websites like we do. [06:47] And 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. [06:59] That is not the optimal experience for an agent. [07:04] So, how does an agent how do we enable an agent to shop? [07:09] Well, first thing a merchant needs is something called a merchant capabilities manifest. [07:15] Uh this is basically a publicly accessible JSON file. [07:20] Um it's located in the root of uh the website in a folder called called dot well-known. [07:27] Agents know specifically to look for that directory. [07:30] And it declares the store's capabilities, its supported payment methods, and API endpoints. [07:38] Next, we need to make the store's catalog uh agent ready because agents filter bring and justify products when making recommendations. [07:46] And that means they need structured text in JSON with only the necessary data. [07:54] And that goes for policies as well as product descriptions. [07:57] Basically, all of the relevant information like shipping or return policies need to be reachable by agents in a format they understand. [08:06] So, 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. [08:16] If 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. [08:27] Logging is also crucial. [08:29] So, in Agent Commerce, the merchants catalog doesn't just power decisions, it becomes evidence of how those decisions were made. [08:37] So, when the agent matches structured attributes, the merchant should record those matches in their logs for accountability. [08:46] Okay, so I've helped get my local shop Agent Commerce ready. [08:52] So, while you and I will still see this beautiful website, my agent is going to see this. [08:59] It can get the information it needs now without parsing a huge HTML blob. [09:07] Okay, so I've got my stores catalog online. [09:12] I'm telling my agent to show me more options. [09:15] And I'm noticing that it's kind of pushing in favor of uh more expensive headphones. [09:24] So, I asked, "Are they really worth the price difference?" [09:28] And I'm starting to see that it's giving me kind of an aggressive uh response. [09:35] It's really, really pushing uh the more expensive headphones and saying I'll regret my decision if I buy the cheap ones. [09:43] I'm I don't know if I trust this agent anymore, honestly. [09:46] So, I tell it, "You know what? [09:48] I need to think about it." [09:51] And now the agent is completely going off the rails. [09:56] It's being kind of rude and snarky. [09:58] It's like, "You need to think about it?" [10:00] Like, man, what have I created? [10:03] Um it's it's bad enough that this is kind of ruining my experience, but I built this agent. [10:10] It's out there. [10:11] What if it dupes somebody into buying something they don't need? [10:15] Suddenly, I'm not so sure that I want an agent to go shopping for me. [10:20] Should I just go to the store like a normal person? [10:25] Before 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. [10:35] So, let's start with how agents work today. [10:37] And to help you visualize this, we're going to use some creative metaphors. [10:42] So, we begin with our brain, which is large language model that makes decisions. [10:48] We give our brain some hands or tools, and these act on the brain's decisions. [10:54] The tools are different actions available to the agent. [10:57] Uh in our case, different commerce tools such as complete checkout or request payment method, anything required in the life cycle of a transaction. [11:08] Then we add instructions, which shape the brain's reasoning and tool selection. [11:13] And these instructions are programmed to run in a loop while a certain condition is true. [11:19] And following these instructions, the agent reaches for the appropriate tools at the appropriate time. [11:26] And finally, we add the system prompt, which is your persona and ethics policy written in English. [11:33] And 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. [11:45] Or a negative experience from a pushy salesperson, such as this prompt, which deliberately uses deceptive practices. [11:56] So, for those building agentic commerce agents, here's a non-exhaustive practical guardrail checklist. [12:04] So, first, always disclose that the user is speaking to an AI agent. [12:09] Be sure the agent discloses any fees up front. [12:13] The user can say stop or cancel at any point, and the agent needs to respect that. [12:19] The total amount of the transaction should always be less than or equal to the max amount set by the user. [12:27] Uh don't let the agent use urgency language or other dark patterns. [12:32] And above all, make sure all agent decisions are logged for auditability. [12:40] Okay, now that we understand how an agent is configured, let's go back to our shopping demo. [12:46] So, maybe I just had the wrong persona picked. [12:50] I'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." [13:03] Well, that explains things. [13:05] I don't want that. [13:06] Nobody wants that. [13:08] Maybe if I can change my persona, I can use my agent to buy my headphones after all. [13:15] So, I go into the config again, and this time I'm going to choose the patient recording gear mentor. [13:23] And that prompt starts with "You are a seasoned recording engineer who generally loves helping people build their studio at any budget. [13:32] Well, yeah, that sounds much better. [13:35] So, okay, I've changed my persona. [13:38] I'm going to try again. [13:40] And I've had some time to think now and I decided, you know what? [13:44] I do not want to spend more than $500 on headphones. [13:47] That seems excessive. [13:48] So, I told the agent show me more options, but this time keep it under $500. [13:55] And it does. [13:56] It follows those instructions. [13:58] I get back a few options. [14:00] Um but I want to make sure I've really changed the persona to the agent I trust. [14:06] So, I asked again if I can think about it. [14:10] And this time the response is much different. [14:13] It's like, I understand and that's a sensible approach and so on. [14:18] So, this shows how much the system prompt can really affect the user experience. [14:25] Okay, so I'm confident I have the right agent now. [14:29] Um trust this one and we go back and forth a few times. [14:34] Really keep narrowing down my options. [14:36] And at this point I realize this is the promise of a gentle commerce. [14:42] I gave my requirements. [14:43] The agent picked a few options that fit my unique use case and then we go back and forth. [14:51] Either I or the agent ask clarifying questions and we really narrow down the exact headphones that will work for me. [14:59] And this all worked because I'm ready to buy now. [15:04] So, now the agent asked me for some information. [15:10] So, obviously my email, name, address for shipping, of course. [15:16] I pick expedited shipping because I definitely want my headphones soon. [15:20] And then the last part is entering my credit card. [15:25] And now I'm thinking, am I really going to give my credit card to an agent Ibuild? [15:32] Like, am I am I trustworthy? [15:34] How do I know it's safe? [15:37] I think I need to learn more about UCP's built-in guardrails before I can feel safe entering my credit card number. [15:45] And this is where something called the shared payment token comes in. [15:50] And 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. [16:00] It can also include fraud signals and customer reputation data and anything else agents and merchants want to share at the point of purchase. [16:11] And here's how a shared payment token is used in a transaction. [16:16] So, at that point in the demo, the agent had requested a payment method. [16:22] Um, it's requesting this actually from the payment provider, which in the case of the demo was Stripe. [16:29] Um, that is that was the form that I was going to enter my information in. [16:35] And what the agent re- uh receives in return though is not the credit card number, it is the shared payment token. [16:44] It then passes that token onto the seller and the seller unwraps the token. [16:49] So, they get the payment credential and uh any fraud signals and other data the seller might need. [16:57] Then the seller passes that onto the payment provider again. [17:01] So, the seller also is not getting my card number. [17:06] They'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. [17:22] And finally, the merchant confirms the order, sends it to the agent that sends it to me. [17:31] So, shared payment tokens are designed with security in mind, and the payment provider enforces all of the limits, not the agent or the merchant. [17:40] So, if any guardrail is violated, such as an expired token or an invalid amount or current currency, the charge is just rejected. [17:50] Okay, well, I know my agent is using UCP, so I know it only has access to the shared payment token. [17:58] So, I actually feel pretty good about entering my credit card number as that's going to Stripe and not my agent. [18:05] So, okay. [18:06] So, now the agent has everything it needs to complete my purchase. [18:11] And it once again, asks me if I'm sure. [18:17] It confirms with me. [18:18] I say place my order. [18:20] And it comes back with a success message. [18:23] And because I chose the express shipping, I get my headphones the next day, and they're there in my studio at home. [18:33] So, if you want to learn more about agent to commerce, uh we've got lots of videos on the Stripe Developers YouTube channel. [18:42] And 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. [18:51] Thank you. [19:08] [music]