> your AI agent picks dependencies from memory; give it dated facts — try starlog.dev ↗ vet your agent's deps ↗ vibe-coding is fine. vibe-importing isn’t. — try starlog.dev ↗ vibe-importing isn’t fine ↗ your agent has never seen your private packages — try starlog.dev ↗ facts for private packages ↗ a linter for the dependencies your AI agent picks — try starlog.dev ↗ a linter for agent deps ↗

Back to Articles

MiroFish: Building Prediction Engines with Swarm Intelligence and Multi-Agent Simulation

[ View on GitHub ]

MiroFish: Building Prediction Engines with Swarm Intelligence and Multi-Agent Simulation

Hook

What if you could predict a presidential election outcome not by polling thousands of real people, but by simulating thousands of AI agents who read the same news, form opinions, argue on social media, and organically shift their views over time?

Context

Traditional forecasting relies on statistical models, historical patterns, and regression analysis. These approaches excel at predicting structured phenomena—stock prices following technical patterns, weather systems obeying physical laws, sales trends with seasonal cycles. But they struggle with messy human systems where predictions depend on millions of individual decisions influenced by social dynamics, narrative shifts, and unpredictable interactions.

MiroFish takes a radically different approach inspired by swarm intelligence—the emergent collective behavior seen in ant colonies, bird flocks, and human societies. Instead of fitting curves to historical data, it constructs a digital parallel world populated by autonomous agents. Each agent consumes knowledge from a graph database, develops memories and personality traits through LLM prompting, interacts with other agents on simulated social platforms, and evolves opinions over time. The prediction emerges not from calculation but from observation: after running the simulation forward, what did the collective intelligence produce? Created by developer 666ghj and accumulating nearly 60,000 GitHub stars, MiroFish represents a paradigm shift from modeling systems mathematically to simulating them socially.

Technical Insight

MiroFish's architecture consists of four major components orchestrated by a Python backend with a Node.js frontend. First, the knowledge construction layer uses GraphRAG to transform seed data—news articles, research reports, historical records, or even fictional narratives—into a knowledge graph. This graph doesn't just store facts; it captures relationships, temporal sequences, and contextual connections that agents will query during simulation.

Second, the agent generation system creates digital personas using LLM prompts. Each agent receives a procedurally generated background including demographics, personality traits, knowledge domains, and initial beliefs. Here's a simplified example of how an agent might be initialized:

from mirofish import Agent, PersonalityProfile

# Create an agent with specific traits
voter_agent = Agent(
    profile=PersonalityProfile(
        age=34,
        occupation="software_engineer",
        education="masters",
        personality_traits={
            "openness": 0.7,
            "conscientiousness": 0.8,
            "extraversion": 0.4
        },
        initial_beliefs={
            "tech_regulation": "moderate_support",
            "privacy_concerns": "high"
        }
    ),
    memory_backend="zep_cloud",
    llm_config={
        "provider": "qwen",
        "model": "qwen-plus"
    }
)

# Agent queries knowledge graph and forms opinions
opinion = voter_agent.process_event(
    event_data=knowledge_graph.query("recent_tech_policy_news"),
    context=simulation.current_state
)

The third component is the dual-platform simulation environment where agents don't just exist—they interact. MiroFish implements simulated social media and communication channels where agents post content, respond to others, form connections, and shift opinions based on social influence. This is where swarm intelligence emerges: no central controller dictates outcomes, but patterns arise from thousands of micro-interactions. The system integrates Zep Cloud for persistent agent memory, allowing agents to accumulate experiences across simulation rounds and exhibit temporal consistency in their behavior changes.

Crucially, MiroFish supports temporal updates to the knowledge graph during simulation. As agents progress through simulated time periods, new information can be injected—breaking news, policy announcements, external shocks. Agents consume this information asynchronously based on their social networks and attention patterns, creating realistic information diffusion dynamics. The documentation warns users to limit initial runs to under 40 rounds due to LLM API costs, as each round might involve thousands of agent inference calls.

The fourth component is the ReportAgent, a specialized LLM agent that observes the simulation, analyzes emergent patterns, and synthesizes prediction reports. Unlike the participant agents, the ReportAgent maintains a god's-eye view of all interactions, tracking sentiment shifts, opinion clustering, viral information cascades, and consensus formation. This architectural separation between simulation participants and observer-analyst mirrors social science research methodology.

What makes MiroFish particularly powerful is the 'God Mode' intervention system. During simulation, you can inject variables—a scandal breaking, a policy reversal, an economic shock—and watch the agent swarm reorganize its collective behavior in response. This turns prediction into scenario rehearsal: not just 'what will happen' but 'what would happen if.' The system supports any OpenAI-compatible API endpoint, with the developers recommending Alibaba's Qwen-plus model for Chinese language scenarios and performance balance.

Gotcha

The elephant in the room is validation: how do you know if your agent-based prediction reflects reality or just LLM hallucination at scale? MiroFish provides no built-in evaluation framework, no backtesting methodology, no confidence intervals. The agents are only as good as the LLMs powering them, inheriting all their biases, inconsistencies, and tendency to generate plausible-sounding nonsense. If your LLM has absorbed stereotypes from training data, your thousand simulated agents will exhibit those same stereotypes. Unlike statistical models where you can validate against holdout data and compute error metrics, agent-based predictions are fundamentally difficult to verify until the future actually happens.

The computational costs escalate brutally with simulation complexity. A 40-round simulation with a few thousand agents might consume hundreds of thousands of LLM tokens. That warning in the documentation about keeping initial tests under 40 rounds? It's there because users were probably burning through API credits faster than they expected. You're also locked into external dependencies: Zep Cloud for memory management and whatever LLM provider you choose. There's no fully self-hosted option, meaning you're sharing potentially sensitive scenario data with third-party services. For organizations exploring geopolitical scenarios, policy impacts, or proprietary business strategies, this dependency might be a non-starter. The codebase also assumes familiarity with both GraphRAG concepts and multi-agent frameworks—there's a learning curve before you can meaningfully customize agent behaviors or simulation dynamics beyond the provided examples.

Verdict

Use if: You're exploring complex social systems where emergence matters—policy impact assessment, public opinion modeling, market behavior with social components, or creative scenario development. You have budget for LLM API experimentation and value exploratory 'what-if' analysis over precise point predictions. You're comfortable with qualitative insights from simulation and understand the limitations of agent-based modeling. This shines for organizations doing strategic foresight, think tanks modeling policy interventions, or researchers studying collective behavior dynamics. Skip if: You need defensible, statistically rigorous forecasts with confidence intervals for production decision-making. You're working in domains where agent simulation assumptions break down (physical systems, purely technical systems). You require real-time predictions or have limited API budgets. You need full data sovereignty without external service dependencies. For those cases, stick with traditional forecasting frameworks like Prophet or statsmodels, or if you need multi-agent capabilities for other purposes, consider more general frameworks like AgentScope or academic tools like Concordia that come with peer-reviewed methodology.