🦑 Society of Mind Council: Open, Multi-Agent World Generation with RAG & LLMs

Community Article Published September 26, 2025

Brandon “Dim” Husbands, Witchborn Systems (TX 501c3 nonprofit, EIN 39-4322774)
info@witchbornsystems.org | witchbornsystems.org


Abstract

How do we create worlds, not just stories, with AI?
This article presents a plug-and-play “Society of Mind” council—a multi-agent, retrieval-augmented LLM engine for generating era-locked, internally consistent, and original myth, lore, and chapters.
We show how simple roles (“Narrator”, “LoreKeeper”, “Trickster”, etc.), retrieval-augmented Codex, and a single context variable can create living canon for any genre or setting, all in a single notebook or workflow.

Developed at Witchborn Systems, a Texas nonprofit dedicated to explainable, corrigible, and public-benefit AI.


Why Society of Mind?

"No single AI is as corrigible, creative, or world-consistent as a council of purpose-driven minds."

Most LLM-driven storytelling tools remix tropes, drift between genres, or lose canon.
By simulating a council of specialized roles—each with memory, purpose, and constraints—we get a living writers’ room:

  • Each “agent” advances, critiques, or refines the draft.
  • Retrieval-augmented generation (RAG) locks every round to current world/canon.
  • Era/context locking ensures your world, rules, and characters never “drift.”
  • Output is always clean (no code, no markdown)—pure narrative, ready for books, games, or Codex expansion.

The Codex is the world’s evolving “memory.” It remembers laws, myths, prior decisions—and as the council invents new events or rules, those can be added back to the Codex as new canon. The system can recall (for continuity), or create (for growth), depending on council debate and your Codex settings.


Quickstart: Minimal Setup

No repo needed—just copy-paste these cells in Colab or a notebook.

# Minimal install (Colab)
!pip install -q transformers accelerate huggingface_hub langchain faiss-cpu

import os, gc, re
import torch

1. Project Config: Any World, Any Era

PROJECT_NAME = "SocietyOfMindDemo"

# Change this for any book, timeline, or genre:
CONTEXT_PREFIX = (
    "ERA: The Age of Ascendancy. This story/world is set 1000 years before the Great Cataclysm. "
    "No references to the Old Order or events after the Ascendancy. All lore, council, and events must reflect this era."
)

AGENT_ROLES = [
    "Narrator", "LoreKeeper", "Editor", "Trickster", "RNGMaster", "Archivist", "ContextAgent"
]

2. Codex/RAG: Memory and Law

# Example Codex (can be JSON, text, etc.)
CODEX = [
    {"text": "ERA: The Age of Ascendancy. This Codex covers laws, myths, and history of the Ascendant world, before the Cataclysm. All events and magic must be original to this era."},
    {"text": "The sky is ruled by twin moons. Each city is built around an ancient obelisk. Magic is wild, governed by moon phases."},
    {"text": "Technology exists as relics—steam and crystal. Guilds compete for power, each guided by a mythical beast."},
    {"text": "Shards are not places, but moments—each a living memory, which can be entered or altered by the brave."},
    # Add more as needed!
]

3. Agent Remits (Generic Roles & Example)

EXAMPLE_TRANSCRIPT = """
Narrator: The story opens as the council gathers under twin moons. Each councilor brings their own agenda and fear.
LoreKeeper: Log the central law, core myth, and a new relic for this world.
Editor: Clarify what makes this timeline distinct; cut any prior canon echoes.
Trickster: A new member blunders in, causing chaos. Give them a name and a funny disaster.
RNGMaster: Roll a unique blessing or curse for this world; no copy-paste.
Archivist: Canon: new law, myth, and anomaly logged for this era.
ContextAgent: ✅ No timeline bleed. All responses are original to this setting.
"""

4. Council Debate Function (Drop-in)

def get_rag_context_with_era(query, docs, n=4):
    # Always include the era chunk (docs[0]), plus top N-1 retrieved (simple slice for demo)
    context_docs = [docs[0]] + docs[1:n]
    return context_docs

def council_debate(topic, roles, docs, rounds=2, max_tokens=110):
    transcript = []
    for rnd in range(rounds):
        lore_hits = get_rag_context_with_era(topic, docs, n=4)
        lore_context = "\n---\n".join([d["text"] for d in lore_hits])
        for role in roles:
            prompt = f"""{CONTEXT_PREFIX}
Council is acting as a writers' room. Each agent gives 2-3 sentences to advance the draft.
Instructions:
- {role}: {EXAMPLE_TRANSCRIPT.splitlines()[roles.index(role)][len(role)+2:]}
Topic: {topic}

Relevant Lore Context:
{lore_context}

# CURRENT TRANSCRIPT
{"".join(transcript[-12:])}

# YOUR TURN
{role}:"""
            # For demo, just output the role and a placeholder. Plug in your LLM as needed!
            out = f"{role}: [LLM-generated line for {role} in this context]"
            transcript.append(out)
            print(out)
    return transcript

5. Synthesis: Clean, Era-Locked Output

def strip_code_blocks(text):
    return re.sub(r"```[\s\S]*?```", "", text, flags=re.MULTILINE)

You can run this on any output (chapter, summary, etc) before saving/export.


6. Example: Generate a New World Fragment

# Step 1: Invent a new city or crisis for this era.
outline_topic = "Invent a new city and crisis for this era. No reference to prior canon."
transcript = council_debate(outline_topic, AGENT_ROLES, CODEX, rounds=2)

# Step 2: Synthesize (plug into LLM if desired, or just print transcript for brainstorming!)
# Step 3: (Optional) Clean output
# clean_text = strip_code_blocks(full_text)

7. How to Use for Any World

  • Change CONTEXT_PREFIX and CODEX[0] for any world/era/canon (fantasy, scifi, horror, RPG, education, etc.)
  • Swap/add agent roles as desired
  • Plug in your favorite LLM or pipeline where “LLM-generated line” is noted
  • Use outputs as new canon, Codex, or world seeds

8. Extending the Council

  • Add a MetaAgent for live world audits
  • Add player or collaborator votes for canonization
  • Save output as Codex entries for future runs or world forks

9. Sample Output (Conceptual)

Narrator: The story opens as the council gathers beneath twin moons in a city built around an ancient obelisk...
LoreKeeper: The core law of this world: No spell may be cast without a witness. The myth of the First Moon’s Shadow still shapes city politics.
Editor: This timeline has never seen the Old Order. Remove any accidental references.
Trickster: Someone knocks over the moonstone—chaos ensues!
RNGMaster: Blessing: Every 99 years, a blue comet grants one city unlimited dreams—but only if the obelisk is intact.
Archivist: Canon: Law, myth, blessing registered for the Era of Ascendancy.
ContextAgent: ✅ Canon clean. No timeline bleed, no Old Order references.

Why This Matters (and Where It Came From)

This pipeline is part of ongoing research and creative tooling at Witchborn Systems, a Texas nonprofit dedicated to ensuring AI serves the public good—by making creative AI both corrigible and transparent.

We use this framework for world-gen, AI authorship, game design, and creative research. You can, too!


Contact & License

Developed by Brandon “Dim” Husbands at Witchborn Systems, TX nonprofit (EIN 39-4322774)
Contact: info@witchbornsystems.org
Web: witchbornsystems.org

MIT License. Copy, remix, cite—please credit and share improvements!


Try this in Colab, Jupyter, or plug into your favorite RAG/LLM stack.
Fork, remix, and let your own council forge the future of AI narrative.

(If you want Witchborn, Iron Tower, or any other IP as a concrete demo, just swap in your context and codex!)

End of Line

Community

Sign up or log in to comment