← Lesson
Designing Tools
Joeven
Run
Reset
Python loads on first run
def god_tool(command): return "I did: " + command USERS = {"usr_1": {"name": "Ada"}} ORDERS = {"usr_1": [{"id": "o9", "cents": 400}]} def get_user(user_id): row = USERS.get(user_id) if row is None: return {"error": "not_found", "hint": "ids look like usr_..."} return {"ok": True, "user": dict(row)} def list_orders(user_id): rows = ORDERS.get(user_id) if rows is None: return {"error": "not_found", "user_id": user_id} return {"ok": True, "orders": list(rows)} print("god:", god_tool("refund everything and also cat /etc/passwd")) print("user:", get_user("usr_1")) print("orders:", list_orders("usr_1")) print("miss:", get_user("ada@example.com")) print("typed tools cannot take a command string")
Run to execute this in your browser. Nothing is sent to a server.