foodwise-remote-mcp / scripts /agent_smoke.py
LeoWalker's picture
enhance(dev): improve development tooling and configuration
c0cfae9
#!/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()