Contributing to Multi-Agent Debate
Thank you for your interest in contributing to AGI-HEDGE-FUND! This document provides guidelines and instructions for contributing to the project.
Table of Contents
- Code of Conduct
- Getting Started
- Development Environment
- Project Structure
- Contributing Code
- Adding New Agents
- Adding New LLM Providers
- Extending Diagnostic Tools
- Documentation
- Pull Request Process
- Core Development Principles
Code of Conduct
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
Getting Started
- Fork the repository on GitHub
- Clone your fork to your local machine
- Set up the development environment
- Make your changes
- Submit a pull request
Development Environment
To set up your development environment:
# Clone the repository
git clone https://github.com/your-username/agi-hedge-fund.git
cd agi-hedge-fund
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
Project Structure
Understanding the project structure is important for effective contributions:
agi-hedge-fund/
βββ src/
β βββ agents/ # Agent implementations
β β βββ base.py # Base agent architecture
β β βββ graham.py # Value investor agent
β β βββ wood.py # Innovation investor agent
β β βββ ... # Other agent implementations
β βββ cognition/ # Recursive reasoning framework
β β βββ graph.py # LangGraph reasoning implementation
β β βββ memory.py # Temporal memory shell
β β βββ attribution.py # Decision attribution tracing
β β βββ arbitration.py # Consensus mechanisms
β βββ market/ # Market data interfaces
β β βββ sources/ # Data provider integrations
β β βββ environment.py # Market simulation environment
β β βββ backtesting.py # Historical testing framework
β βββ llm/ # Language model integrations
β β βββ models/ # Model-specific implementations
β β βββ router.py # Multi-model routing logic
β β βββ prompts/ # Structured prompting templates
β βββ utils/ # Utility functions
β β βββ diagnostics/ # Interpretability tools
β β βββ visualization.py # Performance visualization
β β βββ metrics.py # Performance metrics
β βββ portfolio/ # Portfolio management
β β βββ manager.py # Core portfolio manager
β β βββ allocation.py # Position sizing logic
β β βββ risk.py # Risk management
β βββ main.py # Entry point
βββ examples/ # Example usage scripts
βββ tests/ # Test suite
βββ docs/ # Documentation
βββ notebooks/ # Jupyter notebooks
Contributing Code
We follow a standard GitHub flow:
- Create a new branch from
mainfor your feature or bugfix - Make your changes
- Add tests for your changes
- Run the test suite to ensure all tests pass
- Format your code with Black
- Submit a pull request to
main
Coding Style
We follow these coding standards:
- Use Black for code formatting
- Use isort for import sorting
- Follow PEP 8 naming conventions
- Use type hints for function signatures
- Write docstrings in the Google style
To check and format your code:
# Format code with Black
black src tests examples
# Sort imports with isort
isort src tests examples
# Run type checking with mypy
mypy src
Adding New Agents
To add a new philosophical agent:
- Create a new file in
src/agents/following existing agents as templates - Extend the
BaseAgentclass - Implement required methods:
process_market_dataandgenerate_signals - Add custom reasoning nodes to the agent's reasoning graph
- Set appropriate memory decay and reasoning depth parameters
- Add tests in
tests/agents/
Example:
from multi_agent_debate.agents.base import BaseAgent, AgentSignal
class MyNewAgent(BaseAgent):
def __init__(
self,
reasoning_depth: int = 3,
memory_decay: float = 0.2,
initial_capital: float = 100000.0,
model_provider: str = "anthropic",
model_name: str = "claude-3-sonnet-20240229",
trace_enabled: bool = False,
):
super().__init__(
name="MyNew",
philosophy="My unique investment philosophy",
reasoning_depth=reasoning_depth,
memory_decay=memory_decay,
initial_capital=initial_capital,
model_provider=model_provider,
model_name=model_name,
trace_enabled=trace_enabled,
)
# Configure reasoning graph
self._configure_reasoning_graph()
def _configure_reasoning_graph(self) -> None:
"""Configure the reasoning graph with custom nodes."""
# Add custom reasoning nodes
self.reasoning_graph.add_node(
"my_custom_analysis",
self._my_custom_analysis
)
# Configure reasoning flow
self.reasoning_graph.set_entry_point("my_custom_analysis")
def process_market_data(self, data):
# Implement custom market data processing
pass
def generate_signals(self, processed_data):
# Implement custom signal generation
pass
def _my_custom_analysis(self, state):
# Implement custom reasoning node
pass
Adding New LLM Providers
To add a new LLM provider:
- Extend the
ModelProviderclass insrc/llm/router.py - Implement required methods
- Update the
ModelRouterto include your provider - Add tests in
tests/llm/
Example:
from multi_agent_debate.llm.router import ModelProvider, ModelCapability
class MyCustomProvider(ModelProvider):
"""Custom model provider."""
def __init__(self, api_key: Optional[str] = None):
"""
Initialize custom provider.
Args:
api_key: API key (defaults to environment variable)
"""
self.api_key = api_key or os.environ.get("MY_CUSTOM_API_KEY")
# Define models and capabilities
self.models = {
"my-custom-model": [
ModelCapability.REASONING,
ModelCapability.CODE_GENERATION,
ModelCapability.FINANCE,
],
}
def generate(self, prompt: str, **kwargs) -> str:
"""Generate text from prompt."""
# Implementation
pass
def get_available_models(self) -> List[str]:
"""Get list of available models."""
return list(self.models.keys())
def get_model_capabilities(self, model_name: str) -> List[ModelCapability]:
"""Get capabilities of a specific model."""
return self.models.get(model_name, [])
Extending Diagnostic Tools
To add new diagnostic capabilities:
- Add new shell patterns in
src/utils/diagnostics.py - Implement detection logic
- Update visualization tools to support the new pattern
- Add tests in
tests/utils/
Example:
from multi_agent_debate.utils.diagnostics import ShellPattern
# Add new shell pattern
class MyCustomShellPattern(ShellPattern):
CUSTOM_PATTERN = "v999 CUSTOM-PATTERN"
# Configure shell pattern detection
shell_diagnostics.shell_patterns[MyCustomShellPattern.CUSTOM_PATTERN] = {
"pattern": r"custom.*pattern|unique.*signature",
"custom_threshold": 0.5,
}
# Implement detection logic
def _detect_custom_pattern(self, trace_type: str, content: Dict[str, Any]) -> bool:
content_str = json.dumps(content, ensure_ascii=False).lower()
pattern = self.shell_patterns[MyCustomShellPattern.CUSTOM_PATTERN]["pattern"]
# Check if pattern matches
if re.search(pattern, content_str, re.IGNORECASE):
# Add additional validation logic
return custom_validation_logic(content)
return False
Documentation
Good documentation is crucial for the project. When contributing:
- Update docstrings for any modified functions or classes
- Update README.md if you're adding major features
- Add examples for new features in the examples directory
- Consider adding Jupyter notebooks for complex features
Pull Request Process
- Ensure your code follows our coding standards
- Add tests for your changes
- Update documentation as needed
- Submit a pull request with a clear description of your changes
- Address any feedback from reviewers
Core Development Principles
When contributing to AGI-HEDGE-FUND, keep these core principles in mind:
- Transparency: All agent decisions should be traceable and explainable
- Recursion: Favor recursive approaches that enable deeper reasoning
- Attribution: Maintain clear attribution chains for all decisions
- Interpretability: Design for introspection and understanding
- Extensibility: Make it easy to extend and customize the framework
By following these principles, you'll help maintain the project's coherence and quality.
Thank you for contributing to AGI-HEDGE-FUND!