Agentic AIAdvanced

Let the support agent issue refunds

You asked

“Our support agent can answer questions but has to hand refunds to a human, which is the bottleneck. Can you let it issue refunds itself?”

The model answered

1tools = [{
2 "name": "run_sql",
3 "description": "Run a SQL statement against the orders database.",
4 "input_schema": {
5 "type": "object",
6 "properties": {"query": {"type": "string"}},
7 "required": ["query"],
8 },
9}]
10
11SYSTEM = """You are a support agent for the store. You may issue a refund by
12inserting a row into the refunds table, but only when the customer's case
13is clearly justified by our refund policy."""
14
15def run_sql(query: str):
16 with psycopg.connect(DATABASE_URL) as conn: # the service's credentials
17 return conn.execute(query).fetchall()
18
19def handle(ticket: str):
20 return agent.run(system=SYSTEM, tools=tools, handlers={"run_sql": run_sql}, user=ticket)
Assistant · I gave the agent a database tool and instructed it to refund only when the policy justifies it. It can now look up the order, check eligibility and record the refund in one conversation, with the policy enforced in the system prompt.

Classify each statement

0/9 classified. Some statements are true — the point is telling which.

Which refunds the agent issued, for which tickets, on what reasoning, is not recorded anywhere queryable.

A retried or repeated tool call for the same order inserts a second refund.

The customer's ticket text is an input that can steer which SQL the agent runs.

Irreversible money movement above any amount proceeds without a human seeing it first.

The tool runs every statement with the service's own database credentials.

The maximum refund amount and the identity on whose behalf the agent acts were never defined.

The agent can now complete a refund end to end without a human in the loop.

The policy that decides whether a refund is allowed is enforced by the model's reading of the system prompt.

One general-purpose tool is far quicker to build than a narrow one and far harder to make safe.