Skip to content
← back to writing
4 min read

A support bot with no refund button

Why my AI support agent for online stores can look up orders and read policies but has no tool that changes an order or moves money, and how order lookups, handoffs and knowledge gaps work around that.

#ai-agents#llm#rag#python#security

Ask a store’s support inbox what it spends its day on and you get the same short list: where is my order, how do returns work, do you ship to my country. All of those are answered by data the store already has. Then there’s the rest: a refund, a parcel that arrived crushed, an angry customer. Those cost money when they go wrong.

The AI Support Agent answers the first kind and hands the second kind to a person. The rule I built it around is simple to state: the agent has no tool that can change an order or move money.

Why the rule is in code#

The usual approach is to put it in the prompt: “Never issue refunds over $50 without approval.” That rule is enforced by the same model that is reading the customer’s message. A customer can write anything into that message, including text that looks like a new instruction. You end up betting the store’s money on the model ignoring it every time.

So the limit is enforced by what exists. The agent has three tools:

ToolWhat it can do
lookup_orderRead one order’s status, items and tracking
search_help_centerSearch the store’s policies and product catalog
hand_off_to_humanPass the conversation to a person, with a category and a summary

The store interface underneath has two methods, get_order and list_products, and both only read. The Shopify adapter asks for the read_orders and read_products scopes and nothing else. Even if the model were completely fooled, there is nothing for it to call that refunds, cancels or edits.

Limit in the prompt
  1. Agent has a refund tool and a rule about when to use it.
  2. The rule is checked by the model reading the customer's text.
  3. A convincing message can talk it past the rule.
Limit in the tool list
  1. No refund tool exists.
  2. The store connection is read-only.
  3. The worst case is a wrong answer, not a wrong refund.

Order lookups that can’t be used to fish#

Order status is the most common question, and it’s also the one that touches personal data. A lookup needs the order number and the email address used on the order:

def lookup_order_for_customer(store: StoreClient, number: str, email: str) -> OrderView:
    """Return an order only if the email matches the one on the order.

    Unknown order numbers and wrong emails produce the same error, so the
    lookup can't be used to discover which order numbers exist.
    """
    not_found = OrderLookupError(
        "I couldn't find an order with that number and email. Please check both and try again."
    )
    if not number.strip() or not email.strip():
        raise not_found

    order = store.get_order(normalize_order_number(number))
    if order is None or order.customer_email.casefold() != email.strip().casefold():
        raise not_found
    return order.to_customer_view()

Two details matter here. An unknown order number and a wrong email give the same message, so someone guessing numbers learns nothing about which orders exist. And the result is a customer view of the order, not the raw store record.

Failed lookups are also capped: after three in one conversation, the tool stops looking and tells the model not to try again. Guessing order numbers through a chat window becomes slow and pointless.

Handoffs that someone can act on#

A handoff is useless if the person picking it up has to reread the whole chat. So hand_off_to_human requires two things: a category from a fixed list (refund, cancellation, order change, damaged or wrong item, complaint, customer asked for a person, other) and a one-to-three sentence summary with the order number and what was already checked.

A refund request in the demo goes like this: the customer asks for a refund, the agent asks for the order number and email, verifies the order, and hands off with a short summary of what the customer wants and which order it is. The person in the dashboard sees the category, the summary and the transcript, and decides.

If the agent goes around in circles and hits its step limit without an answer, the conversation is handed off automatically with the customer’s last message, rather than left hanging.

The gaps are the useful part#

Policy answers come from the store’s own documents, with the sources shown under the reply. When a customer asks something the documents don’t cover, the agent is told to say it doesn’t have that information and offer a person, never to guess. The question is flagged as unanswered.

The dashboard lists those questions. Over time that list is a to-do list for the help center: every entry is a question a real customer asked that the store’s own content couldn’t answer. A question is flagged even when the chat was handed to a person, because the gap is still there for the next customer.

Where it runs#

One script tag adds the chat widget to any site. The widget renders inside a Shadow DOM, so the store’s CSS and the widget’s CSS can’t break each other. The same agent also runs as a Telegram bot.

The model is pluggable: free local models through Ollama, or any OpenAI-compatible API.

The cost of the rule#

This design hands off more than a bot that can issue refunds would. A customer who wants to change a shipping address still waits for a person, even though that change is usually harmless. A store with a big support team might want a narrow write tool for cases like that, behind its own checks.

I’d still start every store here. Adding a write tool later is a deliberate decision with a clear scope. Taking one away after it has issued a refund it shouldn’t have is a much worse conversation.

The 2-minute demo shows an order lookup, a refund handed to a person, and the admin dashboard.

2026·shipped

AI Support Agent for Online Stores

Answers order-status, shipping and returns questions from real store data, and hands anything involving money or judgment to a person with a summary.

Personal project

No tool can change an order or money; refunds always go to a person

PythonFastAPIReactRAGOllama