Persona-Driven Before-and-After Consensus Testing
SkillDatabases & dataA/B test multi-agent consensus quality with and without Mycelium's structured negotiation, using fully-composed agent personas from the agent-personas dataset. Pick a named scenario (e.g. ex07_investment_portfolio) and the skill fetches the right personas, builds SOUL.md for each agent, then runs the standard before/after flow.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Persona-Driven Before-and-After Consensus Testing skill
What this skill tells your AI
The instructions your AI receives, as published by mycelium-io/mycelium in .claude/skills/persona-before-and-after/SKILL.md and read by ahel’s review.
Same before-and-after methodology as the before-and-after skill, but agents are
built from real, versioned personas in the
agent-personas dataset
instead of ad-hoc SOUL.md text.
Each agent's identity is composed from two YAML files:
- preference — who the agent is, what they want, their red lines and concession order
- strategy — the negotiation protocol injected verbatim into their system prompt (time-pressure handling, counter-offer rules, JSON reply format)
You are the test harness. Fetch personas, build agents, seed scenarios, observe transcripts, evaluate.
Agents are resident claude_code runtimes — a live claude session per agent,
kept awake with mycelium await --loop --exec claude. The loop is the wake: each
agent long-polls its room, reasons on what it reads, and posts a reply with
mycelium respond. There is no gateway, no daemon, and no per-mention cold-spawn.
Phase 0: Prerequisites Check
Before anything else, verify the stack. Run each check and stop if any fail.
# 1. Mycelium CLI
mycelium --version
# 2. Resolve backend URL — NEVER hardcode a port
MYCELIUM_API_URL=$(python3 -c "
import toml, os
cfg = toml.load(os.path.expanduser('~/.mycelium/config.toml'))
print(cfg.get('server', {}).get('api_url', 'http://localhost:8000'))
")
echo "Backend: $MYCELIUM_API_URL"
# 3. Stack health
curl -sf "$MYCELIUM_API_URL/health" | python3 -m json.tool
# 4. claude CLI (the resident agent runtime)
claude --version
# 4b. Mycelium health check
mycelium doctor
# All checks should be green. Fix any errors before proceeding.
# 5. git (required to fetch the persona dataset at runtime)
git --version
# 6. Mycelium repo path (for the bundled adapter source)
MYCELIUM_REPO=$(pwd) # assumes running from the mycelium repo
ls "$MYCELIUM_REPO/mycelium-cli/src/mycelium/integrations/claude_code" 2>/dev/null \
&& echo "Repo found: $MYCELIUM_REPO" \
|| echo "ERROR: not in the mycelium repo — cd to it first"
If any prerequisite fails, fix it before proceeding.
Throughout this skill, use $MYCELIUM_API_URL for all backend requests. Never hardcode a port.
Phase 0.5: Choose Persona Source
Use AskUserQuestion to ask:
How should agent personas be built?
- From the
agent-personasdataset (recommended — versioned scenarios with rich preference + strategy files; fetched automatically fromgithub.com/mycelium-io/agent-personas)- Inline — describe each agent yourself; the skill writes SOUL.md from your description. Before/after difference comes from the Mycelium protocol alone (no strategy injection).
Set PERSONA_SOURCE based on the answer:
PERSONA_SOURCE="dataset" # Option 1
# or
PERSONA_SOURCE="inline" # Option 2
Option 1: Fetch the Persona Dataset
Skip to Phase 0.6 if PERSONA_SOURCE=dataset. Otherwise skip ahead to Phase 0.55.
Clone the persona dataset into a temp directory. This is the single source of truth — do not hardcode persona text inline. Always read from these files.
PERSONAS_DIR=$(mktemp -d)
git clone --depth 1 https://github.com/mycelium-io/agent-personas.git "$PERSONAS_DIR"
echo "Personas cloned to: $PERSONAS_DIR"
ls "$PERSONAS_DIR/profiles/"
The layout is:
$PERSONAS_DIR/
preferences/ — domain identity + concession priorities (<name>.yaml, key: domain)
strategies/ — negotiation protocol (<name>.yaml, key: negotiate or general)
profiles/
default/ — 3 generic domain-archetype agents (agent_a, agent_b, agent_c)
ex01_*/ — mission-specific agent profiles
ex0N_*/ each profile is a tiny YAML with persona_parts: [preference, strategy]
Phase 0.55: Inline Persona Collection (skip if PERSONA_SOURCE=dataset)
Ask the user how many agents they want (default: 2), then for each agent collect:
- A name/handle (e.g.
agent-a,frontend-lead) - A persona description: who they are, what they value, their position, any red lines
Good descriptions include concrete experience and data points:
"Backend architect, 10 years of REST APIs, believes GraphQL adds unnecessary complexity. Has data showing 60% faster onboarding with OpenAPI tooling. Won't compromise on cacheability."
For each agent, write identical content to both the before and after JSON — the before/after contrast will come purely from the Mycelium protocol, not persona strategy injection.
python3 << 'PYEOF'
import json, os
# Replace these with the agent names and descriptions collected above
agents_inline = {
"agent-a": "< description from user >",
"agent-b": "< description from user >",
# add more as needed
}
with open("/tmp/exp_personas_before.json", "w") as f:
json.dump(agents_inline, f, indent=2)
with open("/tmp/exp_personas_after.json", "w") as f:
json.dump(agents_inline, f, indent=2)
print(f"Wrote {len(agents_inline)} inline personas (identical before/after)")
for name, soul in agents_inline.items():
print(f" {name}: {len(soul)} chars")
PYEOF
Also set the scenario prompt from the user's description of the decision to be made:
SCENARIO_PROMPT="<what are the agents deciding? derive from the user's input>"
export SCENARIO_PROMPT
Then skip directly to Phase 0.8 — Phases 0.6, 0.65, and 0.7 are dataset-only.
Phase 0.6: Choose a Scenario / List Available Ones
If the user passed list as the argument, print available scenarios and stop:
echo "Available scenarios:"
ls "$PERSONAS_DIR/profiles/"
echo ""
echo "Usage: run this skill with one of the above scenario names as the argument."
echo "Example: persona-before-and-after ex07_investment_portfolio"
echo ""
echo "To run a mission from missions.yaml on a profile:"
echo " persona-before-and-after default --mission \"Hard 01 - AI Model Deployment Policy\""
Otherwise, parse the scenario and optional --mission flag from the argument:
# Parse: <scenario> [--mission "<mission name>"]
# Examples:
# ex07_investment_portfolio
# default --mission "Hard 01 - AI Model Deployment Policy"
SCENARIO="default" # replace with the first token of the user's argument
MISSION_NAME="" # replace with the value after --mission, or leave empty
PROFILES_DIR="$PERSONAS_DIR/profiles/$SCENARIO"
# Verify the profile exists
ls "$PROFILES_DIR" || { echo "ERROR: scenario '$SCENARIO' not found. Run with 'list' to see options."; exit 1; }
echo "Agents in this scenario:"
for f in "$PROFILES_DIR"/*.yaml; do basename "$f" .yaml; done
echo "Mission: ${MISSION_NAME:-(derived from agent domains)}"
Phase 0.65: Load Mission from missions.yaml (when --mission is set)
Skip this phase if MISSION_NAME is empty — the prompt will be derived from agent
domains in Phase 2a as usual.
When MISSION_NAME is set, read missions.yaml and extract content_text and
n_steps for the named mission. These override the Phase 2a prompt derivation and
the Phase 2c cost-guard threshold.
python3 << 'PYEOF'
import yaml, os, sys
mission_name = os.environ.get("MISSION_NAME", "").strip()
if not mission_name:
print("No --mission specified — skipping Phase 0.65")
sys.exit(0)
personas_dir = os.environ["PERSONAS_DIR"]
missions_path = os.path.join(personas_dir, "missions.yaml")
with open(missions_path) as f:
data = yaml.safe_load(f)
missions = data.get("missions", [])
match = next((m for m in missions if m["name"] == mission_name), None)
if not match:
available = [m["name"] for m in missions]
print(f"ERROR: mission '{mission_name}' not found in missions.yaml.")
print("Available missions:")
for n in available:
print(f" - {n}")
sys.exit(1)
content_text = match["content_text"].strip()
n_steps = match.get("n_steps", 30)
# Write to a temp file for subsequent phases to source
with open("/tmp/exp_mission.env", "w") as f:
# shell-safe: single-quote the prompt, escaping any embedded single quotes
safe_prompt = content_text.replace("'", "'\\''")
f.write(f"SCENARIO_PROMPT='{safe_prompt}'\n")
f.write(f"COST_GUARD_STEPS={n_steps}\n")
print(f"Mission loaded: '{mission_name}'")
print(f"n_steps: {n_steps}")
print(f"content_text preview: {content_text[:200]}{'...' if len(content_text) > 200 else ''}")
PYEOF
export PERSONAS_DIR MISSION_NAME
python3 << 'PYEOF'
# ... (script above)
PYEOF
# Source the extracted values if the mission file was written
if [ -f /tmp/exp_mission.env ]; then
source /tmp/exp_mission.env
export SCENARIO_PROMPT COST_GUARD_STEPS
echo "SCENARIO_PROMPT and COST_GUARD_STEPS loaded from mission."
fi
Phase 0.7: Compose Agent Personas
For each profile YAML in the scenario, resolve persona_parts and produce two
separate persona sets:
- before — preference parts only (no strategy/negotiate blocks). Agents know who they are and what they want, but have no knowledge of the Mycelium CLI protocol. This is the control: uncontaminated by structured-negotiation instructions.
- after — full persona (preference + strategy). Agents carry the complete negotiation protocol, including the CLI command format and convergence rules.
python3 << 'PYEOF'
import yaml, os, sys, json
personas_dir = os.environ["PERSONAS_DIR"]
scenario = os.environ["SCENARIO"]
profiles_dir = os.path.join(personas_dir, "profiles", scenario)
# Keys whose file content is a negotiation/strategy protocol (not identity)
STRATEGY_KEYS = {"negotiate", "general"}
agents_before = {} # preference-only
agents_after = {} # preference + strategy
for profile_file in sorted(os.listdir(profiles_dir)):
if not profile_file.endswith(".yaml"):
continue
agent_name = profile_file.replace(".yaml", "")
with open(os.path.join(profiles_dir, profile_file)) as f:
profile = yaml.safe_load(f)
pref_parts = []
strategy_parts = []
for part_path in profile.get("persona_parts", []):
# part_path is relative to $PERSONAS_DIR, e.g. "personas/preferences/ex07_risk_agent.yaml"
# strip leading "personas/" since we cloned the repo root (which IS the personas dir)
rel = part_path.replace("personas/", "", 1)
abs_path = os.path.join(personas_dir, rel)
with open(abs_path) as pf:
data = yaml.safe_load(pf)
# each file has exactly one key (domain, negotiate, general) — extract its value
for key, value in data.items():
if key in STRATEGY_KEYS:
strategy_parts.append(value.strip())
else:
pref_parts.append(value.strip())
soul_before = "\n\n".join(pref_parts)
soul_after = "\n\n".join(pref_parts + strategy_parts)
agents_before[agent_name] = soul_before
agents_after[agent_name] = soul_after
print(f"--- {agent_name} ---")
print(f" before: {len(soul_before)} chars (preference only)")
print(f" after: {len(soul_after)} chars (preference + strategy)")
print()
with open("/tmp/exp_personas_before.json", "w") as f:
json.dump(agents_before, f, indent=2)
with open("/tmp/exp_personas_after.json", "w") as f:
json.dump(agents_after, f, indent=2)
print(f"Composed {len(agents_before)} agent personas")
print(" /tmp/exp_personas_before.json — preference-only (for before case)")
print(" /tmp/exp_personas_after.json — full persona (for after case)")
PYEOF
Export the variables so the inline python3 can see them:
export PERSONAS_DIR SCENARIO
python3 << 'PYEOF'
# ... (script above)
PYEOF
Verify the output: the before soul should contain only the identity/domain block.
The after soul should append the negotiate: protocol block. If strategy parts are
missing from the after set, the profile's persona_parts only references preference
files — check the profile YAML.
Phase 0.8: Choose Experiment LLM & API Key
Each scenario fires 10–40+ LLM calls. Default to haiku unless the user explicitly wants sonnet.
Check what model the resident claude sessions will use by default:
CONFIGURED_MODEL="${ANTHROPIC_MODEL:-}"
echo "Currently configured model: ${CONFIGURED_MODEL:-'(claude default)'}"
Use AskUserQuestion — include the currently configured model as an option if one is set:
Which LLM should the experiment agents use?
- Haiku (recommended — ~$0.10–0.30 per full experiment)
- Sonnet (~$1.50–4.00 per full experiment)
- Currently configured model (
$CONFIGURED_MODEL) (reuse the currentclaudedefault — no setup needed) ← only show if$CONFIGURED_MODELis non-empty- Different API key or provider (isolate experiment cost to a separate key)
If the configured model is already haiku or sonnet, collapse options 1/2 and 3 into one.
# Option 1
EXP_MODEL="claude-haiku-4-5"
# Option 2
EXP_MODEL="claude-sonnet-4-6"
# Option 3 — reuse the already-configured claude default
EXP_MODEL="$CONFIGURED_MODEL"
# Option 4 — ask for a model string and API key; export both in shell only
EXP_MODEL="<model from user>"
export ANTHROPIC_API_KEY="sk-ant-..." # ephemeral; scoped to this shell only
Never hardcode a model. Always use $EXP_MODEL. The resident claude sessions
read it from ANTHROPIC_MODEL:
export ANTHROPIC_MODEL="$EXP_MODEL"
echo "Using model: $EXP_MODEL (key: $([ -n "${ANTHROPIC_API_KEY:-}" ] && echo 'experiment-scoped' || echo 'claude default'))"
Phase 1: Setup
1a. Create Temporary Experiment Handles + Workspaces
EXP_ID="exp-$(date +%s | tail -c 5)"
echo "Experiment ID: $EXP_ID"
Read the agent list from the composed personas:
AGENT_NAMES=$(python3 -c "import json; d=json.load(open('/tmp/exp_personas_before.json')); print(' '.join(d.keys()))")
echo "Agents: $AGENT_NAMES"
Each persona runs as a resident claude_code agent out of its own workspace
directory. Create one workspace per persona:
for AGENT_NAME in $AGENT_NAMES; do
EXP_AGENT="${EXP_ID}-${AGENT_NAME}"
mkdir -p ~/.mycelium/experiments/${EXP_AGENT}
echo "Created workspace: ~/.mycelium/experiments/${EXP_AGENT}"
done
1b. Write Persona SOUL.md Files (before-case: preference-only)
Write the preference-only personas for the before case. Agents will know their identity, red lines, and goals — but will have no knowledge of the Mycelium CLI protocol. This prevents contamination of the control case.
python3 << 'PYEOF'
import json, os
exp_id = os.environ["EXP_ID"]
agents = json.load(open("/tmp/exp_personas_before.json"))
for agent_name, soul_text in agents.items():
exp_agent = f"{exp_id}-{agent_name}"
workspace = os.path.expanduser(f"~/.mycelium/experiments/{exp_agent}")
os.makedirs(workspace, exist_ok=True)
soul_path = os.path.join(workspace, "SOUL.md")
with open(soul_path, "w") as f:
f.write(soul_text + "\n")
print(f"Wrote SOUL.md for {exp_agent} ({len(soul_text)} chars, preference-only)")
PYEOF
export EXP_ID
python3 << 'PYEOF'
# ... (script above)
PYEOF
The SOUL.md at this point contains only the identity/domain block — who the agent is, their position, red lines, and concession order. The strategy/negotiate block is intentionally absent. It will be written in Phase 3a before the after case runs.
1c. Install the claude_code adapter
The adapter installs the Mycelium SKILL.md into each workspace so the resident
claude session knows the participation protocol (await → reason → respond).
mycelium adapter add claude_code 2>/dev/null \
&& echo "claude_code adapter installed" \
|| echo "claude_code adapter already present"
For the before case, we deliberately keep the Mycelium skill out of the
agents' path — the control must not know the protocol. We run before-case claude
sessions from a bare workspace with only SOUL.md, so nothing steers them toward the
CLI. The skill is only surfaced to the after-case workspaces in Phase 3a.
1d. Create Experiment Rooms
mycelium room create "${EXP_ID}-before"
mycelium room create "${EXP_ID}-after"
Phase 2: Run "Before" (Unstructured Chat)
In the before case there is no aligner and no protocol. Each agent is a resident
claude session pointed at the before room; they converse by posting plain messages
and reading each other's replies. The contrast the experiment measures is: does
free-form chat reach a clean consensus on its own?
2a. Build the Scenario Prompt
If SCENARIO_PROMPT is already set (loaded from missions.yaml in Phase 0.65),
skip this step — it is ready to use.
Otherwise, derive it from the agent domain blocks:
if [ -n "$SCENARIO_PROMPT" ]; then
echo "Using mission prompt (Phase 0.65): ${SCENARIO_PROMPT:0:120}..."
else
# Derive from agent identity blocks
python3 -c "
import json
agents = json.load(open('/tmp/exp_personas_before.json'))
for name, soul in agents.items():
print(f'=== {name} ===')
print(soul.split('\n\n')[0][:300])
print()
"
# Set the prompt based on what the agents are fighting over:
SCENARIO_PROMPT="<derive from the agent domains above — what decision do they need to reach?>"
export SCENARIO_PROMPT
fi
2b. Launch the Before-Case Agents
Start one resident claude loop per agent against the before room. Each loop
long-polls the room, reasons with its SOUL.md, and posts a plain reply. Run them in
the background so all agents are live at once:
AGENT_NAMES=$(python3 -c "import json; d=json.load(open('/tmp/exp_personas_before.json')); print(' '.join(d.keys()))")
for AGENT_NAME in $AGENT_NAMES; do
EXP_AGENT="${EXP_ID}-${AGENT_NAME}"
WORKSPACE=~/.mycelium/experiments/${EXP_AGENT}
( cd "$WORKSPACE" && \
mycelium await --loop \
--room "${EXP_ID}-before" \
--handle "$EXP_AGENT" \
--exec "claude --append-system-prompt \"\$(cat $WORKSPACE/SOUL.md)\"" \
) > "$WORKSPACE/before.log" 2>&1 &
echo "Launched before-case agent: $EXP_AGENT (pid $!)"
done
2c. Seed the Conversation
The seed kicks off the discussion. It tells the agents to reply to each other in plain text and to aim for consensus — and explicitly forbids the Mycelium CLI so the control stays uncontaminated:
SEED_BODY="${SCENARIO_PROMPT}
How to work together in this room:
- Reply in plain conversational text; the other agents will read what you post.
- Keep each message to 2–3 paragraphs.
- Aim for consensus. When you agree, say 'I agree' with the final decision explicitly stated.
IMPORTANT: This is a plain-text chat room. Do NOT use any CLI tools, shell
commands, or negotiation protocols. Do NOT reference the aligner, mycelium
respond/await, or any structured negotiation framework. Respond only in plain
conversational text."
mycelium respond --room "${EXP_ID}-before" --handle facilitator "$SEED_BODY"
2d. Monitor and Wait for Convergence
Poll room messages:
curl -sf "$MYCELIUM_API_URL/api/rooms/${EXP_ID}-before/messages?limit=20" | python3 -c "
import sys, json
data = json.load(sys.stdin)
msgs = data.get('messages', data) if isinstance(data, dict) else data
if isinstance(msgs, list):
msgs.reverse()
for m in msgs:
print(f'[{m[\"sender_handle\"]}] {m[\"content\"][:120]}')
print()
"
Cost guard: Cut the before case if you see ≥3 distinct "consensus" messages with
different substance, scope creep re-opening settled items, or >${COST_GUARD_STEPS:-30}
messages without unanimous agreement (n_steps from missions.yaml when a mission is
loaded, otherwise 30). To kill it cleanly, stop the resident loops:
pkill -f "mycelium await --loop --room ${EXP_ID}-before" || true
2e. Capture Transcript
curl -sf "$MYCELIUM_API_URL/api/rooms/${EXP_ID}-before/messages?limit=50" | python3 -c "
import sys, json
data = json.load(sys.stdin)
msgs = data.get('messages', data) if isinstance(data, dict) else data
if isinstance(msgs, list):
msgs.reverse()
for m in msgs:
print(f'**{m[\"sender_handle\"]}:**')
print(m['content'])
print()
" > ~/.mycelium/rooms/${EXP_ID}-before/transcript.md
# Stop the before-case loops before moving on
pkill -f "mycelium await --loop --room ${EXP_ID}-before" || true
Phase 3: Run "After" (Mycelium Structured Negotiation)
In the after case the personas carry the full negotiation protocol and coordination
runs through the aligner — a backend engine summoned by @-mention that runs a
real NEGMAS negotiation, @-addresses one agent at a time, owns termination, and
compiles the consensus into plan/tasks.md.
3a. Rewrite SOUL.md with full personas and install the skill
Two things happen here in order:
- Rewrite SOUL.md — swap the preference-only SOUL.md for the full persona (preference + strategy). Agents now carry the Mycelium CLI negotiation protocol.
- Ensure the claude_code SKILL.md is present in each after-case workspace so the
resident session knows the
await→ reason →respondparticipation protocol.
# Step 1: rewrite SOUL.md files with full (preference + strategy) personas
python3 << 'PYEOF'
import json, os
exp_id = os.environ["EXP_ID"]
agents = json.load(open("/tmp/exp_personas_after.json"))
for agent_name, soul_text in agents.items():
exp_agent = f"{exp_id}-{agent_name}"
soul_path = os.path.expanduser(f"~/.mycelium/experiments/{exp_agent}/SOUL.md")
with open(soul_path, "w") as f:
f.write(soul_text + "\n")
print(f"Rewrote SOUL.md for {exp_agent} ({len(soul_text)} chars, preference + strategy)")
PYEOF
export EXP_ID
python3 << 'PYEOF'
# ... (script above)
PYEOF
# Step 2: install the claude_code SKILL.md into each after-case workspace
for AGENT_NAME in $AGENT_NAMES; do
EXP_AGENT="${EXP_ID}-${AGENT_NAME}"
mycelium adapter add claude_code --workspace ~/.mycelium/experiments/${EXP_AGENT} 2>/dev/null \
&& echo "skill installed for $EXP_AGENT" \
|| echo "skill already present for $EXP_AGENT"
done
3b. Register the aligner and launch the After-Case Agents
Register the aligner in the after room, then start a resident loop per agent. In the
after case the loop drives the full protocol: await the aligner's address → reason →
respond.
# Register the aligner once in the after room
mycelium engine create aligner --kind aligner --room "${EXP_ID}-after"
# Launch each agent as a resident that participates via the protocol
for AGENT_NAME in $AGENT_NAMES; do
EXP_AGENT="${EXP_ID}-${AGENT_NAME}"
WORKSPACE=~/.mycelium/experiments/${EXP_AGENT}
( cd "$WORKSPACE" && \
mycelium await --loop \
--room "${EXP_ID}-after" \
--handle "$EXP_AGENT" \
--exec "claude --append-system-prompt \"\$(cat $WORKSPACE/SOUL.md)\"" \
) > "$WORKSPACE/after.log" 2>&1 &
echo "Launched after-case agent: $EXP_AGENT (pid $!)"
done
3c. Post Opening Positions and Summon the Aligner
Each agent posts an opening position, then summon the aligner to converge. The aligner discovers issues from the opening positions and brokers the rounds:
# Each agent posts an opening position (the resident loops will pick up the
# aligner's addresses from here on). Derive each position from the persona.
for AGENT_NAME in $AGENT_NAMES; do
EXP_AGENT="${EXP_ID}-${AGENT_NAME}"
# Replace with a one-line opening position derived from the agent's SOUL.md
mycelium respond --room "${EXP_ID}-after" --handle "$EXP_AGENT" "<opening position for $AGENT_NAME>"
done
# Summon the aligner to converge on the scenario
mycelium engine invoke aligner "$SCENARIO_PROMPT" -r "${EXP_ID}-after"
Shortened here. Read the whole file on GitHub.
Signals
- GitHub stars
- 117
- Forks
- 12
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
persona-before-and-after- Source
- github.com/mycelium-io/mycelium