AI Hints
Home›Agentic AI Tutorial›Agents at Work
Agentic AI · Lesson 83 of 100

Many Customers, One Agent

Keeping data apart.

⏱ 2 min read▶ Video at 2:26:12🎓 Free
Watch this lesson in the Agentic AI courseWatch on YouTube ↗Full Agentic AI course

Priya asks Juno about order B forty two. That's Sam's order. If Juno reads it out, that's a data breach. The model doesn't know who owns what, and you can't ask it to remember. So who's logged in has to be enforced somewhere that the model can't touch.

Many Customers, One Agent
From the video: Many Customers, One Agent
  • Priya asks about Sam's order
  • That's a data breach
  • Enforce it where the model can't reach

Identity outside the model

Look at the tool. It takes a user argument, which is set by the session, and the model never gets to see that. The model only supplies the order number. Inside, the tool checks who owns the order. Run it. Priya can see her own order. When she asks for Sam's, she gets, no such order, as if it didn't exist. Nothing that a customer types can change the user, because it never goes through the model. Never let the model pass the user ID, or an attacker will simply ask it to.

tenant.pypython
ORDERS = {"A17": {"owner": "priya", "price": 640}, "B42": {"owner": "sam", "price": 28}}

def get_order(order_id, *, user):
    order = ORDERS.get(order_id)
    if order is None or order["owner"] != user:
        return {"error": "No such order"}
    return order

class Session:
    def __init__(self, user):
        self.user = user

    def call(self, tool, **args):
        return tool(**args, user=self.user)

priya = Session("priya")
print(priya.call(get_order, order_id="A17"))
print(priya.call(get_order, order_id="B42"))
Output
{'owner': 'priya', 'price': 640}
{'error': 'No such order'}

Isolation checklist

For every shared agent, check these. Tools get the user from the session, never from the model. Memory stores are separated by user. Search filters by account, before the model sees any results. Logs are protected too. And caches don't mix users, because a shared answer can leak someone's data. Test this directly, by logging in as one user, and asking for another's data.

Identity from sessionnever from the model
Separate memoryper user
Filter searchbefore the model
Mind the cachesno shared answers
Test ittry to cross over

Summary

Identity lives outside the model. Next, let's learn from when agents go badly wrong.

Key takeaways
  • The model never sets the user
  • Tools check ownership
  • Test across accounts
Next up: When Agents Went Wrong — lessons from real failures