Real World Example

Where Agents Are Used

  • Food and grocery delivery support (Swiggy, Zomato style): the bot looks up the order, checks delivery partner status, applies the refund policy and issues a coupon or refund within limits.
  • Coding agents (GitHub Copilot agent mode, Claude Code): read files, run tests, edit code, repeat until tests pass.
  • Research assistants (Perplexity style): search, read several pages, then write an answer with citations.
  • Fintech operations (Razorpay, PhonePe style): agents collect transaction details and draft a dispute response for a human to approve.

ShopEase Return Agent

import anthropic
from anthropic import beta_tool

client = anthropic.Anthropic()
ORDERS = {"SE1042": {"item": "Boat Airdopes 141", "delivered_days_ago": 4, "price": 1299, "category": "electronics"}}

@beta_tool
def get_order(order_id: str) -> str:
    """Get a ShopEase order. Call this first whenever an order ID is mentioned.

    Args:
        order_id: Order ID like SE1042.
    """
    return str(ORDERS.get(order_id, "not found"))

@beta_tool
def check_return_eligibility(order_id: str) -> str:
    """Check the return policy for an order. Call before creating a return.

    Args:
        order_id: Order ID like SE1042.
    """
    o = ORDERS[order_id]
    window = 7 if o["category"] == "electronics" else 10
    left = window - o["delivered_days_ago"]
    return f"eligible, {left} days left (replacement only)" if left > 0 else "not eligible"

@beta_tool
def create_return(order_id: str, reason: str) -> str:
    """Create a return pickup. Call only after the customer confirms they want it.

    Args:
        order_id: Order ID like SE1042.
        reason: Short reason given by the customer.
    """
    return f"Return RT-{order_id[-4:]} created, pickup tomorrow 10am-1pm"

runner = client.beta.messages.tool_runner(
    model="claude-sonnet-5-5",
    max_tokens=4000,
    max_iterations=6,      # hard stop on the loop
    system="You are ShopEase support. Check eligibility before creating a return. Keep replies under 60 words.",
    tools=[get_order, check_return_eligibility, create_return],
    messages=[{"role": "user", "content": "My SE1042 earbuds have a crackling sound. Yes, please arrange a return."}],
)
final = runner.until_done()
print(next(b.text for b in final.content if b.type == "text"))

Run it

python return_agent.py

Example output

Sorry about the crackling sound! Your Boat Airdopes 141 (SE1042) are eligible for a
replacement for 3 more days. I have created return RT-1042 - pickup is tomorrow
between 10am and 1pm. Please keep the box and charging case ready.

What Makes It Production Ready

  • Tools check business rules themselves (eligibility, refund limits), not just the prompt.
  • max_iterations and a token budget stop runaway loops.
  • Every tool call is logged with the conversation ID for audits.
  • An eval set of 50-100 real conversations is re-run on every prompt or model change.