{"slug": "i-built-a-17-agent-ai-swarm-on-my-phone-here-s-how", "title": "I built a 17-agent AI swarm on my phone — here's how", "summary": "A developer built a 17-agent AI swarm that runs entirely on a Pixel 7 smartphone, using llama-cpp-python and a quantized Phi-2 model to analyze long-form text and generate tailored social media posts for X, LinkedIn, Facebook, and Instagram. The system splits the task across specialized agents for summarization, keyword extraction, and per-platform post generation, with GPU layers offloaded to the phone's processor.", "body_md": "Okay, buckle up. This is going to be a bit of a deep dive. For the past few weeks I've been obsessing over the idea of running a genuinely useful, multi-agent system *entirely* on a smartphone. Not just a demo, not just a simplified example, but something that could actually perform a relatively complex task. And I did it. I built a 17-agent AI swarm, running on my Pixel 7, that analyzes text and generates targeted social media content. \n\nWhy a phone? Honestly, it's a challenge. We're so used to thinking of AI as cloud-based, reliant on massive servers. But the capabilities of modern smartphone processors are frankly *astonishing*. It forces you to be incredibly efficient, to think about model size, quantization, and creative code architecture. Plus, it’s portable. Where else can you carry a swarm intelligence around in your pocket?\n\nThis isn't about replacing large language models (LLMs) hosted in the cloud. It's about exploring the boundaries of what’s possible *on-device*.\n\n**The Core Idea: Social Media Content Alchemy**\n\nThe goal was to take a relatively long-form piece of text (think a blog post, article, or even a transcript) and automatically generate a set of tailored social media posts for different platforms – Twitter (now X), LinkedIn, Facebook, and Instagram.\n\nThe 'swarm' architecture was crucial. Instead of relying on one big model, I broke the problem down into specialized agents, each handling a specific stage of the process. Think of it like an assembly line, but powered by AI.\n\n**The Agents: A Breakdown of the Swarm**\n\nHere’s a look at the 17 agents and their roles:\n\n**Tech Stack & Challenges**\n\n`transformers` and `llama-cpp-python` libraries.\n**Code Snippets (Illustrative)**\n\nLet's look at some simplified snippets to give you a flavour.\n\n**1. Loading the Model (Python - `llama-cpp-python`)**\n\n``` python\nfrom llama_cpp import Llama\n\nllm = Llama(model_path=\"./phi-2.Q4_K_M.gguf\", n_ctx=2048, n_gpu_layers=-1)  # Use all available GPU layers\n```\n\nThis initializes the Llama model, loading the quantized GGUF file. The `-1` argument tries to offload as many layers as possible to the GPU (which my Pixel 7 has).\n\n**2.  A Simple Agent Function (Post Generator)**\n\n``` python\ndef generate_post(summary, keywords, platform, length):\n    prompt = f\"Generate a {length} social media post for {platform} about the following:\\n\\nSummary: {summary}\\n\\nKeywords: {keywords}\\n\\nPost:\"\n    output = llm(prompt, max_tokens=150, stop=[\"\\n\\n\"], echo=False)\n    return output['choices'][0]['text'].strip()\n```\n\nThis function takes the summarized text, keywords, platform, and desired post length as input and constructs a prompt for Phi-2.  The `stop` parameter prevents the model from generating endlessly.  \n\n**3. Orchestrating the Swarm (Simplified)**\n\n```\npython\n# Load input text\ninput_text = load_text_from_file(\"my_article.txt\")\n\n# Summarize (using the Summarizer agents)\nsummaries = [summarize_text(input_text) for _ in range(2)]\n\n# Extract Keywords (using the Keyword Extractor agents)\nkeywords_sets = [extract_keywords(input_text) for _ in range(2)]\n\n# Average the keyword sets\nkeywords = list(set(keywords_sets[0] + keywords_sets[1])) #Remove Duplicates\n\n# Generate posts for each platform\nplatform_posts = {}\nfor platform in [\"Twitter\", \"LinkedIn\", \"Facebook\", \"Instagram\"]:\n    platform_posts[platform] = [\n        generate_post(summaries[0], keywords, platform, \"short\"),\n        generate_post(summaries[0], keywords, platform, \"medium\"),\n        generate_post(summaries[0], keywords, platform, \"long\")\n    ]\n\n# Print Results\nfor platform, posts in platform_posts.items():\n    print(f\"--- {platform} ---\")\n    for i, post in enumerate(posts):\n        print(\n```\n\n", "url": "https://wpnews.pro/news/i-built-a-17-agent-ai-swarm-on-my-phone-here-s-how", "canonical_source": "https://dev.to/sam_hiotis_117598dbfa3ac2/i-built-a-17-agent-ai-swarm-on-my-phone-heres-how-fb8", "published_at": "2026-10-11 08:39:31+00:00", "updated_at": "2026-10-11 08:51:38.646733+00:00", "lang": "en", "topics": ["ai-agents", "large-language-models", "ai-tools", "generative-ai", "developer-tools"], "entities": ["Pixel 7", "Phi-2", "llama-cpp-python", "transformers", "X", "LinkedIn", "Facebook", "Instagram"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/i-built-a-17-agent-ai-swarm-on-my-phone-here-s-how", "markdown": "https://wpnews.pro/news/i-built-a-17-agent-ai-swarm-on-my-phone-here-s-how.md", "text": "https://wpnews.pro/news/i-built-a-17-agent-ai-swarm-on-my-phone-here-s-how.txt", "jsonld": "https://wpnews.pro/news/i-built-a-17-agent-ai-swarm-on-my-phone-here-s-how.jsonld"}}