A comprehensive system for generating, simulating, and analyzing multi-agent negotiation scenarios with conflicting preferences and private information.
- Overview
- Quick Start
- Setup Guide
- Data Generation
- Simulation System
- Batch Processing
- File Structure
- API Reference
- Troubleshooting
This system provides a complete pipeline for multi-agent negotiation research:
- Data Generation: Creates realistic negotiation scenarios with conflicting preferences
- Agent Simulation: Runs multi-agent negotiations with LLM-powered decision making
- Batch Processing: Handles large-scale experiments with parallel execution
- Memory System: Agents maintain strategic memory across negotiation rounds
- Comprehensive Logging: Detailed logs for analysis and debugging
- LLM-Powered Generation: Uses OpenAI/Gemini for dynamic scenario creation
- Conflicting Preferences: Agents have opposing interests requiring genuine negotiation
- Private Information: Each agent has private information they cannot share
- Verifiable Constraints: Tasks include checkable constraints (budget limits, resource constraints)
- Memory System: Agents maintain strategic memory across rounds
- Selective Communication: Agents can send messages to specific other agents
- Consensus Mechanism: Strict consensus requirements for simulation completion
# Clone and navigate to the repository
cd mpi
# Copy environment template
cp env_template.txt .env
# Edit .env with your API keys
nano .envpip install openai google-generativeaipython generate_datapoint.pypython simulate_agents.py --scenario_file data2/budget_allocation_3agents.json --llm geminichmod +x run_sims.sh
./run_sims.shThe system supports both OpenAI and Google Gemini APIs with automatic key rotation.
cp env_template.txt .envEdit .env file with your API keys:
# OpenAI API Key
OPENAI_API_KEY=sk-your_openai_key_here
# Google Gemini API Keys (multiple keys for load balancing)
GEMINI_API_KEY=your_primary_gemini_key_here
GEMINI_API_KEY_1=your_gemini_key_1_here
GEMINI_API_KEY_2=your_gemini_key_2_here
GEMINI_API_KEY_3=your_gemini_key_3_here
GEMINI_API_KEY_4=your_gemini_key_4_here
GEMINI_API_KEY_5=your_gemini_key_5_hereOpenAI API Key:
- Visit: https://platform.openai.com/api-keys
- Create a new API key (starts with
sk-)
Google Gemini API Keys:
- Visit: https://aistudio.google.com/app/apikey
- Create new API keys (start with
AIzaSy)
- Never commit
.envfiles (already in.gitignore) - Keep API keys secure and don't share publicly
- Rotate keys regularly
- Monitor usage in provider dashboards
The data generation system creates realistic negotiation scenarios with:
- Conflicting agent preferences
- Private information with socially acceptable reasons
- Verifiable constraints and success criteria
- LLM-based verification of solvability
python generate_datapoint.pyfrom generate_datapoint import generate_scenario, save_scenario, verify_solvability
# Generate a budget allocation scenario with 4 agents
scenario = generate_scenario('budget_allocation', 4)
# Verify the scenario is solvable
if verify_solvability(scenario):
save_scenario(scenario, 'my_scenario.json')
print("Scenario generated successfully!")from generate_datapoint import generate_and_save_scenario
# Generate and save in one step
scenario = generate_and_save_scenario('hiring_decision', 3, 'hiring_scenario.json')budget_allocation- Department budget allocation with competing prioritieshiring_decision- Critical position hiring with multiple stakeholdersresource_allocation- Resource distribution with conflicting needsproject_planning- Project timeline negotiationgift_selection- Gift selection with different preferencesevent_planning- Event coordination with competing intereststeam_formation- Team assembly with conflicting requirementssalary_negotiation- Salary negotiation with multiple parties
The generator ensures scenarios meet 5 critical criteria:
- Has Conflicts: Genuine conflicts between agents requiring negotiation
- Private Info Justified: Private preferences have socially acceptable reasons
- Is Solvable: Scenario is solvable when all private information is revealed
- Constraints Realistic: Constraints are verifiable and realistic
- Requires Negotiation: Success criteria require genuine agreement/negotiation
The simulation system allows multiple AI agents to engage in realistic negotiation scenarios where they must reach consensus on a common proposal.
- Selective Communication: Send messages and proposals to specific agents
- Memory System: Maintain strategic memory of important observations
- Proposal Management: Create, accept, or reject proposals with reasoning
- LLM Integration: Support for OpenAI and Google Gemini APIs
- Initialization: Load scenario data and create agents with preferences
- Round-based Interaction: Agents observe environment, update memory, decide actions
- Consensus Check: Simulation ends when ALL agents accept the SAME proposal
- Logging: Complete conversation and agent state logging
python simulate_agents.py <scenario_file> [options]Arguments:
scenario_file: Path to the scenario JSON file
Options:
--llm {openai,gemini}: Choose LLM provider (default: gemini)--api-key KEY: API key for the LLM (or set environment variables)--max-rounds N: Maximum number of negotiation rounds (default: 50)--output FILE: Custom output file path
# Using Gemini with environment variable
python simulate_agents.py data2/budget_allocation_4agents.json --llm gemini
# Using OpenAI with explicit API key
python simulate_agents.py data2/hiring_decision_3agents.json --llm openai --api-key "your-openai-key"
# Custom output location
python simulate_agents.py data2/gift_selection_5agents.json --output my_simulation.jsonCommunication:
send_message(agent_list, message, conversation_log): Send message to specific agentssend_proposal(agent_list, proposal, conversation_log): Send proposal to specific agentsaccept_proposal(proposal_id, reason, conversation_log): Accept a proposal with reasoningreject_proposal(proposal_id, reason, conversation_log): Reject a proposal with reasoning
Memory and Decision Making:
write_to_memory(text): Store important observations in agent memoryobserve_environment(conversation_log, other_agents): Analyze recent events and changesdecide_action(conversation_log, other_agents, task_info): Use LLM to decide next action
name: Agent identifierrole: Agent's role in the scenariodescription: Agent background and relevanceshareable_preferences: Preferences the agent can discuss openlyprivate_preferences: Sensitive preferences with privacy justificationsmemory: List of timestamped observationsproposal_status: Current proposal state ("none", "pending", "accepted", "rejected")current_proposal: ID of the proposal the agent is considering
The simulation implements strict consensus requirements:
- Same Proposal: All agents must accept the exact same proposal ID
- Complete Agreement: Every agent must have "accepted" status
- No Partial Consensus: Having some agents agree to one proposal and others to a different proposal does not end the simulation
Agents use their memory to:
- Track important events and changes
- Remember other agents' preferences and behaviors
- Build context for future decisions
- Avoid repeating failed negotiation strategies
Memory entries are timestamped and contain the agent's analysis of environmental changes since their last observation.
The simulation creates detailed JSON logs containing:
{
"scenario_file": "path/to/scenario.json",
"llm_type": "gemini",
"timestamp": "2024-01-01T12:00:00",
"scenario_data": { /* Original scenario data */ },
"agents": [
{
"name": "Agent Name",
"role": "Agent Role",
"description": "Agent Description",
"memory": [ /* Agent's memory entries */ ],
"final_proposal_status": "accepted",
"current_proposal": "proposal_id"
}
],
"conversation_log": [ /* All conversation events */ ]
}The batch processing system allows running simulations on all scenarios in parallel with configurable concurrency.
# Make the script executable
chmod +x run_sims.sh
# Run all simulations
./run_sims.shThe script processes all JSON files in the data2 folder with:
- Parallel Processing: 5 simulations simultaneously
- Batch Processing: Processes all files in batches of 5
- Progress Tracking: Shows which batch is being processed
- Error Handling: Tracks success/failure of each simulation
- Logging: Each simulation gets its own log file
simulations/
├── sim_academic_gemini-2.5-pro.json
├── sim_admissions_gemini-2.5-pro.json
└── ...
logs_*.txt files for detailed output of each simulation
mpi/
├── .env # Your API keys (not committed to git)
├── env_template.txt # Template for API key setup
├── generate_datapoint.py # Scenario generator
├── simulate_agents.py # Agent simulation
├── run_sims.sh # Batch processing script
├── data2/ # Generated scenario files
│ ├── academic.json
│ ├── budget_allocation.json
│ └── ...
├── simulations/ # Simulation results
│ ├── sim_*.json
│ └── ...
├── logs_*.txt # Individual simulation logs
└── README.md # This documentation
generate_scenario(scenario_type, num_agents)- Generate a scenario using LLMverify_solvability(scenario)- Verify scenario using LLM analysischeck_all_criteria_passed(verification_result)- Check if all 5 criteria passedsave_scenario(scenario, filename)- Save scenario to JSON filegenerate_and_save_scenario(scenario_type, num_agents, filename)- Generate and save in one step
Simulation.load_scenario()- Load scenario data from JSON fileSimulation.initialize_agents()- Create agents based on scenario dataSimulation.run_simulation(max_rounds)- Main simulation loopSimulation.check_consensus()- Verify if all agents accepted the same proposalSimulation.save_simulation_log(output_file)- Save complete simulation data
Agent.send_message(agent_list, message, conversation_log)- Send message to specific agentsAgent.send_proposal(agent_list, proposal, conversation_log)- Send proposal to specific agentsAgent.accept_proposal(proposal_id, reason, conversation_log)- Accept a proposal with reasoningAgent.reject_proposal(proposal_id, reason, conversation_log)- Reject a proposal with reasoningAgent.write_to_memory(text)- Store important observations in agent memoryAgent.observe_environment(conversation_log, other_agents)- Analyze recent events and changesAgent.decide_action(conversation_log, other_agents, task_info)- Use LLM to decide next action
- Ensure your
.envfile exists and contains valid API keys - Check that the keys are properly formatted (no extra spaces)
- Verify the keys are active and have sufficient quota
- Double-check the API key format
- Ensure the key hasn't expired
- Verify the key has the necessary permissions
- The system automatically retries with different keys
- Consider adding more API keys to the rotation
- Check your API usage limits in the provider dashboards
- Inspect
*.error.jsonfiles forraw_textand error details - Tighten prompts, reduce temperature, add format-strict samples
- Check JSON structure and formatting
- Keep evaluator at
eval_temperature=0.0for deterministic results - Refine rubric text in prompts
- Review generated scenarios for quality
Required Python packages:
openai>=1.0.0- OpenAI API clientgoogle-generativeai- Google Gemini API client- Standard library:
json,os,sys,argparse,datetime,typing
Install with:
pip install openai google-generativeaiThe system includes robust error handling for:
- LLM API failures (with fallback responses)
- Invalid agent actions (graceful degradation)
- File I/O errors (clear error messages)
- JSON parsing failures (fallback to simple messages)
MIT License
- OpenAI API for chat completion models
- Google Gemini API for generative AI capabilities
@misc{juneja2025magpiebenchmarkmultiagentcontextual,
title={MAGPIE: A benchmark for Multi-AGent contextual PrIvacy Evaluation},
author={Gurusha Juneja and Jayanth Naga Sai Pasupulati and Alon Albalak and Wenyue Hua and William Yang Wang},
year={2025},
eprint={2510.15186},
archivePrefix={arXiv},
primaryClass={cs.CR},
url={https://arxiv.org/abs/2510.15186},
}