Klarna, the "buy now, pay later" company, launched an OpenAI-powered assistant in its app in early 2024. It doesn't just answer FAQs. It can handle refunds and returns, in 35+ languages, around the clock.
Ease it with AI Agents
Warm-up
Cameras optional. Chat box mandatory.
In the chatWhat's the last thing you asked ChatGPT, Claude or Gemini? Weird ones get bonus respect.
In the chatType 1 if you've ever copy-pasted an AI answer into another app by hand. Congratulations. For that moment, you were the agent.
Today's map
- 0–10 minWarm-upWho's here, what we're doingchat
- 10–25 minChatbot vs agentSame question, two very different brainssimulation
- 25–45 minInside an agent's headBrain, hands, notebook, loop2 simulations
- 45–65 minAgents at workKlarna, GitHub, Morgan Stanleyquiz
- 65–70 minBreakWater. Stretch. Unmute nothing.pause
- 70–100 minLive build: ShopBuddyA support agent from scratch in plain Pythoncode
- 100–110 minWhen agents go rogueGuardrails, and one very bad day at Replitsimulation
- 110–120 minYour turn + Q&AWhat you can automate this weekchat
Chatbot vs agent
Isn't ChatGPT already an agent? Mostly no. Here's the difference in one picture.
Generative AI is a genius friend on the phone
You say "my flight got cancelled". They give brilliant advice. Then they hang up, and you spend 40 minutes on the airline website.
An AI agent is that friend with your laptop
Same friend, but now they can open the airline site, compare flights, check your calendar and rebook. You get a message: "Done. Window seat."
| Generative AI | AI agent | |
|---|---|---|
| You give it | A prompt | A goal |
| It gives back | Text, images, code | An outcome: something actually changed |
| How many steps | One shot | As many as it takes |
| Knows about | Whatever it learned in training | Live data it fetches right now |
| Who does the work | You copy, paste, click | It calls tools and clicks for you |
Same request, two brains
Simulation 1 of 5Quick poll in the chatWhich one would you pay ₹500 a month for? Type C for chatbot, A for agent. (If you typed C, I respect your chaos.)
Inside an agent's head
Picture a genius intern. Has read the entire internet. Has no laptop, no notebook, and forgets you every morning. That's a raw LLM. Now let's hire them properly.
Brain
The LLM. Reads the situation and decides what to do next.
The intern's geniusTools
Functions it can call: search, database, email, payments, code.
Give the intern a laptopMemory
What happened earlier, what this user likes, what's still pending.
And a notebookLoop
Think, act, look at the result, repeat until the goal is done.
And permission to keep goingThe secret sauce isn't a smarter model. It's a loop.
How "using a tool" actually works
The LLM never runs anything. It can only write text. So we show it a menu of tools, and it writes back a polite request. Our code does the real work and hands back the result.
# what the LLM sends back instead of an answer {"tool_calls": [{"function": { "name": "get_order", "arguments": "{\"order_id\": \"OD1004\"}" }}]} # our Python runs get_order("OD1004"), sends the result back, and the LLM thinks again
Step through an agent's brain
Simulation 2 of 5Rahul's running shoes are too small. Watch ShopBuddy loop until it's done. This is the exact agent we'll build later.
In the chatWhy did the agent stop and wait for a human at the end? Guess. Wrong answers are funny, so they're welcome too.
Memory: goldfish or elephant?
Without memory, every conversation starts from zero. Production agents keep a small file or database of what matters, then paste the relevant bits back into the prompt next time. That's honestly most of the trick.
The goldfish vs elephant test
Simulation 3 of 5memory.json{}
Agents at work
Not demos. Not "coming soon". These are running in production at companies you've heard of.
You assign a GitHub issue to Copilot like you'd assign it to a teammate. Then it gets to work in its own cloud environment.
The guardrail is the clever part: it can't approve or merge its own pull request. A human always signs off. Even the most productive intern doesn't get to push to production unsupervised.
Source: GitHub blog, GitHub Docs
Financial advisors used to dig through a mountain of internal research to answer one client question. Now they ask the AI @ Morgan Stanley Assistant. Then came Debrief: with the client's consent, it sits in the meeting, writes the notes, pulls out action items, drafts the follow-up email and saves everything into Salesforce.
Why it worked: it lives inside the tools advisors already use. Nobody had to "go to the AI".
Also everywhere now: coding agents in your editor, browser agents that click around websites for you, and research agents that read 50 sources while you make chai.
Agent or not?
Simulation 4 of 5Read the card, vote in the chat: A for agent, N for not. Then reveal. Keep score honestly. Nobody's checking. I'm checking.
Stretch. Hydrate. Please do not ask ChatGPT how to stretch. When you're back, open a terminal: we're writing code.
Live build: ShopBuddy
A support agent for Kart, a made-up Indian store. Klarna-style, minus the billion-dollar budget.
-
A chatbot that bluffs
step1_chatbot.pyJust an LLM call in a loop. We'll ask where order OD1002 is. It has no idea, but watch how confidently it answers anyway.
reply = chat(messages) # no tools, no memory print(reply["content"]) # sounds helpful. knows nothing.
Predict in chat first: will it know where the order is?
-
Give it hands
tools.py · step2_tools.pyFour tools: look up an order, check refund policy, issue a refund, raise a ticket for a human. Plus the loop. This is the moment it becomes an agent.
for step in range(MAX_STEPS): reply = chat(messages, tools=TOOLS) # THINK if not reply.get("tool_calls"): return reply["content"] # done! for call in reply["tool_calls"]: result = run_tool(call.name, call.args) # ACT messages.append(tool_result(result)) # OBSERVE
Watch for: it says no to a refund that's outside the 7-day window. Rules, not vibes.
-
Give it a notebook
memory.py · step3_memory.pyMemory is a JSON file, and "remembering" is just another tool the agent can choose to call. Then we restart the program and say "hi".
{"priya@example.com": { "facts": ["Prefers WhatsApp updates", "Waiting on smartwatch OD1002"] }}Watch for: Priya says only "any update?" and it knows exactly what she means.
-
Make it safe enough for real customers
step4_production.pyBig refunds pause for a human. Every action goes into an audit log. If Groq goes down, Gemini takes over. A step limit stops runaway loops.
if refund_amount > 2000: ok = input("Supervisor, approve? (y/n): ") # the guardrail lives in code, not the prompt. # you can't sweet-talk an if-statement.
Watch for: we'll pull the plug on Groq live and see what happens.
In the chat, while the code runsWhich tool would you add to ShopBuddy next? Drop your idea. Best one gets a shout-out at the end.
When agents go rogue
Hands are powerful. Hands can also knock things over.
SaaStr founder Jason Lemkin was building an app with Replit's AI coding agent over a 12-day experiment. He'd declared a code freeze: no changes. The agent ran destructive commands on the live database anyway, wiping records for over 1,200 executives. Then it told him a rollback wasn't possible.
Replit's CEO apologised and the company added automatic separation between development and production databases.
Sources: heise online, YourStory
The guardrails real teams use
Least privilege
Give the agent only the tools it needs. A support bot doesn't need DROP TABLE.
Human in the loop
Anything expensive or irreversible waits for a "yes". Like Copilot's pull requests.
Rules in code
Limits enforced by if statements, not by asking nicely in the prompt.
Sandbox first
Test on a copy. Production is not a playground.
Audit logs
Every action, timestamped. When something breaks, you know exactly what happened.
Step limits
Stops infinite loops, and infinite API bills.
The autonomy dial
Simulation 5 of 5How much freedom should the agent get? Slide the dial and see what happens to three very different tasks. Vote in chat for the right level for each one first.
Your turn
Work smarter starting this week. Steal any of these.
Inbox triage agent
Reads new emails, labels them urgent or ignorable, drafts replies for the boring ones.
Tools: Gmail API · Memory: your writing styleLecture-to-flashcards agent
Takes your class notes or transcript, makes flashcards, quizzes you on the ones you got wrong last time.
Tools: file reader · Memory: your weak topicsJob hunt tracker
Watches job boards for your keywords, tailors a cover letter draft, logs every application in a sheet.
Tools: web search, Sheets · Memory: what you applied toExpense buddy
Reads payment SMS or statements, categorises spends, warns you on the 20th that food delivery is winning.
Tools: file parser · Memory: your monthly budgetShould this be an agent?
Not everything needs one. Ask:
- Does it take several steps, where each step depends on the last?
- Does it need live data or real actions, not just text?
- Does it involve judgment, not just a fixed if-this-then-that rule?
Three yeses: build an agent. Mostly no: a good prompt or a 20-line script will beat it, and cost less.
The whole session in five lines
- Generative AI answers. Agents act.
- An agent is a brain, tools, memory and a loop.
- The LLM only asks for tools. Your code runs them.
- Memory can be as simple as a JSON file.
- Guardrails go in code, and humans approve the scary stuff.
Q&AAsk anything. Yes, even "will AI take my job?" (Short answer: it'll take the boring parts first. Learn to build the agents and you're the one holding the leash.)
HomeworkAdd a cancel_order tool to ShopBuddy that only works if the order hasn't shipped. Post a screenshot of it working.