Skip to main content
The SocialAlgorithms framework provides complete flexibility for defining custom communication patterns between agents. Upload any arbitrary social algorithm as a callable that defines exactly how agents interact and communicate.

When to Use

  • Custom communication patterns: Unique agent interaction requirements
  • Research implementations: Test novel multi-agent algorithms
  • Specialized workflows: Domain-specific communication protocols
  • Flexible orchestration: Full control over agent interactions
  • Algorithm experimentation: Compare different social patterns

Key Features

  • Accept any callable as social algorithm
  • Communication history tracking (optional)
  • Execution timeout management
  • Multiple output formats
  • Agent lifecycle management
  • Async execution support
  • Parallel execution options
  • Detailed logging and monitoring

Basic Example

Custom Algorithm Patterns

Debate Algorithm

Hierarchical Review

Consensus Building

Key Parameters

str
default:"SocialAlgorithm"
Name for the algorithm instance
str
Description of the algorithm’s purpose
List[Agent]
required
List of agents that will participate
Callable
required
Function defining the communication pattern (agents, task, **kwargs) -> Any
float
default:"300.0"
Maximum execution time in seconds
OutputType
default:"dict"
Format for output (dict, list, str)
bool
default:"False"
Log all agent communications
bool
default:"False"
Enable parallel execution where possible
bool
default:"False"
Enable detailed logging

Methods

run()

Execute the social algorithm.

run_async()

Asynchronous execution.

add_agent() / remove_agent()

Dynamic agent management.

get_communication_history()

Retrieve communication logs (if enabled).

SocialAlgorithmResult

Detailed execution results:

Use Cases

Multi-Stage Pipeline

Collaborative Writing

Expert Panel

Communication Logging

Track all agent interactions:

Execution Timeout

Output Formatting

Algorithm Requirements

Your social algorithm must:
  1. Accept agents and task: def algorithm(agents, task, **kwargs)
  2. Return results: Any structure (dict, list, str, object)
  3. Handle errors: Exceptions will be caught and logged

Best Practices

Algorithm Design: Keep algorithms focused on communication patterns, not complex logic
  1. Clear Signatures: Always accept (agents, task, **kwargs)
  2. Error Handling: Handle agent failures gracefully
  3. Timeout Awareness: Set appropriate max_execution_time
  4. Communication Logging: Enable for debugging and analysis
  5. Documentation: Document your algorithm’s communication pattern
Social algorithms have full control over agent execution - ensure proper error handling and timeout limits

Error Handling

Agent Management