#!/usr/bin/env python3 """Quick smoke test for the FoodWise inventory agent. Run with: uv run python scripts/agent_smoke.py """ import os import sys from pathlib import Path from dotenv import load_dotenv # Ensure src is on path for direct script execution and pytest collection contexts sys.path.insert(0, str(Path(__file__).parent.parent / "src")) from foodwise.agent.agent import create_inventory_agent, run_agent_query def main() -> None: load_dotenv() if not os.getenv("OPENAI_API_KEY"): print("āŒ OPENAI_API_KEY not found in environment") return if not os.getenv("NOTION_SECRET"): print("āŒ NOTION_SECRET not found in environment") return if not os.getenv("NOTION_INVENTORY_DB_ID"): print("āŒ NOTION_INVENTORY_DB_ID not found in environment") return # Prefer test databases if provided to avoid modifying prod data test_inventory_db = os.getenv("NOTION_INVENTORY_DB_ID_TEST") if test_inventory_db: os.environ["NOTION_INVENTORY_DB_ID"] = test_inventory_db test_shopping_db = os.getenv("NOTION_SHOPPING_DB_ID_TEST") if test_shopping_db: os.environ["NOTION_SHOPPING_DB_ID"] = test_shopping_db print("šŸ¤– Creating FoodWise Inventory Agent...") try: agent = create_inventory_agent() print("āœ… Agent created successfully!") except Exception as e: print(f"āŒ Failed to create agent: {e}") return # Read-only prompts to avoid modifying data in smoke checks test_queries = [ "List a few items from my inventory.", "Which items are expiring soon?", "Search for milk in my inventory.", ] for query in test_queries: print(f"\nšŸ“ Testing: '{query}'") try: response = run_agent_query(query, agent) print(f"šŸ¤– Response: {response}") print("āœ… Query completed successfully!") except Exception as e: print(f"āŒ Query failed: {e}") if __name__ == "__main__": main()