agents.conversation¶
Conversation Agents - Advanced Multi-Agent Dialogue Orchestration System.
This package provides a comprehensive suite of multi-agent conversation orchestrators that facilitate sophisticated agent-to-agent interactions and dialogues. The system enables multiple AI agents to engage in structured conversations following different patterns, protocols, and interaction rules for diverse use cases.
The Conversation framework transforms individual agents into cohesive dialogue systems capable of: - Structured Interactions: Formal debate, moderated discussions, collaborative work - Social Dynamics: Social media simulations, viral content propagation, engagement patterns - Turn Management: Sequential, directed, and dynamic conversation flow control - Role-Based Participation: Speakers, moderators, judges, observers with distinct behaviors - Real-Time Orchestration: Live conversation management with dynamic adaptation
- Core Architecture:
The conversation system is built on a sophisticated multi-layered architecture:
- Foundation Layer - BaseConversationAgent:
Core orchestration engine for all conversation types
Unified state management with message threading and participant tracking
Graph-based workflow integration for complex conversation flows
Real-time turn management and flow control mechanisms
Extensible framework for custom conversation patterns
- State Management System:
ConversationState: Rich state tracking with participant registry, message history
Reducer-based updates: Automatic turn counting, speaker history, progress tracking
Computed properties: Real-time conversation metrics and analysis
Context preservation: Persistent conversation memory across turns
Role-based state views: Agent-specific state projections and permissions
- Conversation Type Specializations:
Each conversation type extends the base with specialized interaction patterns
Unique state schemas, flow control, and participant management
Customizable parameters for different use cases and domains
Integration with domain-specific tools and external systems
- Integration Layer:
Seamless connection with Haive’s core agent system
Tool integration for enhanced conversation capabilities
External system integration (chat platforms, APIs, databases)
Analytics and monitoring integration for conversation insights
- Conversation Types:
- RoundRobinConversation:
Sequential turn-taking with equal participation opportunities
Perfect for panel discussions, brainstorming sessions, group interviews
Configurable turn limits, timeout handling, interruption management
Automatic progress tracking and conversation flow visualization
- DirectedConversation:
Moderator-controlled conversation flow with dynamic speaker selection
Mention-based interaction system for targeted responses
Flexible moderation with custom rules and intervention strategies
Support for both human and AI moderators
- DebateConversation:
Structured formal debates with position-based argumentation
Multiple debate formats: Traditional, Oxford, Parliamentary, Lincoln-Douglas
Comprehensive scoring system with customizable judging criteria
Evidence handling, fact-checking, and citation management
Real-time performance analytics and argument quality assessment
- CollaborativeConversation:
Multi-agent collaboration on shared documents, plans, and projects
Structured document creation with section management and progress tracking
Role-based contribution system with balanced participation
Multiple output formats: Markdown, code, reports, presentations
Real-time collaboration monitoring and quality assessment
- SocialMediaConversation:
Authentic social media platform simulation with viral dynamics
Platform-specific behaviors: Twitter, Instagram, TikTok, LinkedIn styles
Engagement mechanics: Likes, shares, replies, viral propagation
Trending topic tracking and hashtag analysis
Character limits and platform-appropriate content generation
- Agent Capabilities:
- Multi-Agent Coordination:
Dynamic participant management with role assignment and switching
Sophisticated turn management with interruption handling
Parallel and sequential conversation patterns
Cross-conversation state sharing and synchronization
- Conversation Flow Control:
Phase-based conversation management with customizable transitions
Conditional branching based on conversation state and participant behavior
Timeout handling and conversation recovery mechanisms
Real-time conversation monitoring and intervention capabilities
- Social Dynamics Simulation:
Realistic interaction patterns based on participant personalities
Engagement tracking and viral content propagation
Social influence modeling and opinion dynamics
Community formation and interaction network analysis
- Collaborative Work Management:
Task decomposition and assignment with progress tracking
Document structure management with version control
Quality assessment and peer review integration
Deliverable tracking and milestone management
Examples
Basic round robin conversation for team brainstorming:
from haive.agents.conversation import RoundRobinConversation
from haive.agents.simple import SimpleAgent
from haive.core.engine.aug_llm import AugLLMConfig
# Create diverse team members with different perspectives
creative_thinker = SimpleAgent(
name="Alex",
engine=AugLLMConfig(
temperature=0.8,
system_message="You are a creative thinker who brings innovative ideas and thinks outside the box."
)
)
analytical_thinker = SimpleAgent(
name="Morgan",
engine=AugLLMConfig(
temperature=0.3,
system_message="You are an analytical thinker who evaluates ideas critically and focuses on feasibility."
)
)
strategic_thinker = SimpleAgent(
name="Jordan",
engine=AugLLMConfig(
temperature=0.5,
system_message="You are a strategic thinker who considers market implications and business value."
)
)
# Create structured brainstorming conversation
brainstorming = RoundRobinConversation(
name="product_brainstorming",
participants=[creative_thinker, analytical_thinker, strategic_thinker],
topic="Innovative features for our AI assistant product",
max_rounds=4,
config={
"timeout_per_turn": 120,
"allow_follow_up": True,
"require_building_on_previous": True
}
)
# Execute brainstorming session
result = await brainstorming.arun()
print(f"Generated {len(result.ideas)} unique ideas")
print(f"Conversation quality score: {result.quality_metrics.engagement_score}")
Structured debate with comprehensive judging:
from haive.agents.conversation import DebateConversation, create_debate
from haive.agents.simple import SimpleAgent
from haive.core.engine.aug_llm import AugLLMConfig
# Create specialized debate participants
ai_advocate = SimpleAgent(
name="Dr. Sarah Chen",
engine=AugLLMConfig(
temperature=0.4,
system_message="You are an AI researcher who advocates for AI advancement with evidence-based arguments."
)
)
ai_skeptic = SimpleAgent(
name="Prof. Michael Roberts",
engine=AugLLMConfig(
temperature=0.4,
system_message="You are a technology ethicist who raises important concerns about AI risks."
)
)
neutral_judge = SimpleAgent(
name="Judge Williams",
engine=AugLLMConfig(
temperature=0.2,
system_message="You are an impartial judge who evaluates arguments based on logic, evidence, and persuasiveness."
)
)
# Create formal debate with Oxford format
debate = create_debate(
topic="Artificial General Intelligence development should be paused until safety concerns are resolved",
pro_agents=[ai_skeptic], # Pro = pause development
con_agents=[ai_advocate], # Con = continue development
judge_agent=neutral_judge,
rounds=5,
config={
"format": "oxford",
"time_per_round": 300,
"allow_rebuttals": True,
"evidence_required": True,
"scoring_criteria": ["logic", "evidence", "persuasiveness", "rebuttal_quality"]
}
)
# Execute debate and get comprehensive results
debate_result = await debate.arun()
print(f"Winner: {debate_result.winner}")
print(f"Final scores - Pro: {debate_result.pro_score}, Con: {debate_result.con_score}")
print(f"Key arguments: {debate_result.key_arguments}")
Collaborative document creation with role specialization:
from haive.agents.conversation import CollaborativeConversation, create_collaboration
from haive.agents.simple import SimpleAgent
from haive.agents.react import ReactAgent
from haive.core.engine.aug_llm import AugLLMConfig
# Create specialized team members
researcher = ReactAgent(
name="Dr. Emma Thompson",
engine=AugLLMConfig(
tools=[web_search, academic_search, fact_checker],
temperature=0.3,
system_message="You are a thorough researcher who gathers comprehensive, accurate information."
)
)
writer = SimpleAgent(
name="James Wilson",
engine=AugLLMConfig(
temperature=0.7,
system_message="You are a skilled technical writer who creates clear, engaging content."
)
)
editor = SimpleAgent(
name="Lisa Park",
engine=AugLLMConfig(
temperature=0.2,
system_message="You are a meticulous editor who ensures clarity, accuracy, and consistency."
)
)
# Create collaborative writing project
collaboration = create_collaboration(
task="Create a comprehensive white paper on 'The Future of AI in Healthcare'",
participants={
"researcher": researcher,
"writer": writer,
"editor": editor
},
deliverables=[
"executive_summary",
"introduction",
"current_state_analysis",
"future_predictions",
"recommendations",
"conclusion"
],
config={
"document_format": "markdown",
"target_length": 5000,
"citation_style": "APA",
"progress_tracking": True,
"quality_gates": True
}
)
# Execute collaborative writing process
white_paper = await collaboration.arun()
print(f"Document completed: {white_paper.word_count} words")
print(f"Quality score: {white_paper.quality_metrics.overall_score}")
Social media conversation simulation with viral dynamics:
from haive.agents.conversation import SocialMediaConversation
from haive.agents.simple import SimpleAgent
from haive.core.engine.aug_llm import AugLLMConfig
# Create diverse social media personalities
influencer = SimpleAgent(
name="@TechGuru",
engine=AugLLMConfig(
temperature=0.7,
system_message="You are a tech influencer who creates engaging, shareable content about AI trends."
)
)
skeptic = SimpleAgent(
name="@RealityCheck",
engine=AugLLMConfig(
temperature=0.4,
system_message="You are a critical thinker who questions tech hype and asks hard questions."
)
)
enthusiast = SimpleAgent(
name="@FutureFan",
engine=AugLLMConfig(
temperature=0.8,
system_message="You are excited about technology and always share positive, optimistic views."
)
)
casual_user = SimpleAgent(
name="@EverydayUser",
engine=AugLLMConfig(
temperature=0.6,
system_message="You are a regular person who occasionally comments on tech posts."
)
)
# Create social media conversation
social_conversation = SocialMediaConversation(
name="ai_discussion",
participants=[influencer, skeptic, enthusiast, casual_user],
platform="twitter",
topic="Breaking: New AI model achieves human-level performance on complex reasoning tasks",
config={
"character_limit": 280,
"enable_viral_mechanics": True,
"trending_threshold": 10,
"engagement_weights": {"likes": 1, "retweets": 3, "replies": 2}
}
)
# Execute social media interaction
conversation_result = await social_conversation.arun()
print(f"Total interactions: {conversation_result.total_interactions}")
print(f"Viral posts: {conversation_result.viral_posts}")
print(f"Trending hashtags: {conversation_result.trending_hashtags}")
Advanced directed conversation with custom moderation:
from haive.agents.conversation import DirectedConversation
from haive.agents.simple import SimpleAgent
from haive.agents.react import ReactAgent
# Create domain experts
ai_expert = SimpleAgent(name="AI_Expert", engine=ai_config)
ethics_expert = SimpleAgent(name="Ethics_Expert", engine=ethics_config)
policy_expert = SimpleAgent(name="Policy_Expert", engine=policy_config)
business_expert = SimpleAgent(name="Business_Expert", engine=business_config)
# Create intelligent moderator
moderator = ReactAgent(
name="Moderator",
engine=AugLLMConfig(
tools=[question_generator, topic_tracker, time_keeper],
system_message="You are an expert moderator who facilitates productive discussions."
)
)
# Create directed expert panel
panel_discussion = DirectedConversation(
name="ai_governance_panel",
participants=[ai_expert, ethics_expert, policy_expert, business_expert],
moderator=moderator,
topic="Developing responsible AI governance frameworks",
config={
"moderation_style": "socratic",
"ensure_equal_participation": True,
"conflict_resolution": "redirect_to_common_ground",
"follow_up_questions": True
}
)
# Execute moderated discussion
panel_result = await panel_discussion.arun()
print(f"Key insights: {panel_result.key_insights}")
print(f"Consensus areas: {panel_result.consensus_points}")
- Performance Characteristics:
- Execution Performance:
Small conversations (2-4 participants): 2-10 seconds depending on conversation length
Large conversations (5-10 participants): 5-30 seconds with parallel processing optimization
Real-time conversations: <1 second response time for turn transitions
State management: <50ms overhead per turn for conversation state updates
- Scalability Metrics:
Participant limits: 2-50 participants per conversation (optimized for 2-10)
Conversation length: 100+ turns with efficient state management
Concurrent conversations: 10+ simultaneous conversations per instance
Memory efficiency: Optimized message storage and participant state management
- Social Simulation Accuracy:
Engagement prediction: 85%+ accuracy for viral content identification
Platform authenticity: Realistic character limits and interaction patterns
Social dynamics: Accurate representation of influence and opinion propagation
Content quality: Consistent platform-appropriate content generation
- Integration Patterns:
- Chat Platform Integration:
Discord, Slack, Teams integration for live conversation facilitation
Webhook support for real-time conversation monitoring
Message formatting and platform-specific feature support
User authentication and permission management
- Enterprise Workflow Integration:
Meeting facilitation with automated minutes and action items
Collaborative document creation with version control integration
Decision-making processes with structured evaluation and voting
Training and simulation environments for team dynamics
- Research and Analytics:
Conversation pattern analysis and social dynamics research
A/B testing for conversation formats and moderation strategies
Longitudinal studies of opinion formation and consensus building
Behavioral analysis and interaction network mapping
- Advanced Features:
- Dynamic Conversation Management:
Runtime participant addition and removal with role reassignment
Conversation merging and splitting for complex interaction patterns
Real-time conversation monitoring with intervention capabilities
Adaptive flow control based on participant engagement and quality metrics
- AI-Powered Moderation:
Intelligent conflict detection and resolution strategies
Automatic quality assessment and improvement suggestions
Bias detection and mitigation in conversation dynamics
Engagement optimization and participation balancing
- Analytics and Insights:
Comprehensive conversation analytics with participant interaction patterns
Social network analysis and influence mapping
Content quality assessment and improvement recommendations
Predictive modeling for conversation outcomes and participant satisfaction
- Best Practices:
- Conversation Design:
Design clear conversation objectives and success criteria
Select appropriate conversation types for specific use cases
Configure participant roles and permissions thoughtfully
Plan conversation flow and intervention strategies in advance
- Participant Management:
Choose agents with complementary skills and perspectives
Configure agent personalities for realistic and engaging interactions
Balance participation to ensure all voices are heard
Monitor conversation quality and adjust parameters as needed
- Performance Optimization:
Use appropriate conversation types for scale and complexity requirements
Implement efficient state management for long conversations
Monitor resource usage and optimize for concurrent conversations
Cache frequently used conversation patterns and configurations
- Factory Functions:
- create_conversation():
Universal factory for all conversation types with type-safe configuration
Automatic participant validation and role assignment
Built-in conversation flow optimization and error handling
Comprehensive logging and monitoring integration
- create_debate():
Specialized factory for formal debate creation with multiple formats
Automatic scoring system configuration and judge assignment
Evidence tracking and fact-checking integration
Real-time performance monitoring and quality assessment
- create_collaboration():
Optimized factory for collaborative work with deliverable tracking
Role-based task assignment and progress monitoring
Document structure management and version control
Quality gates and milestone tracking integration
- Version History:
- v1.0 (Current):
Complete conversation type implementations with advanced features
Comprehensive state management and real-time orchestration
Social media simulation with viral dynamics and engagement mechanics
Enterprise integration capabilities and analytics platform
- v0.9:
Enhanced debate system with multiple formats and comprehensive scoring
Collaborative conversation improvements with document management
Performance optimizations and scalability improvements
- v0.8:
Initial conversation framework with basic orchestration
Foundation conversation types and state management
Basic participant management and turn control
See also
haive.agents.conversation.base
: Foundation conversation agent implementation
haive.agents.conversation.debate
: Formal debate system with scoring
haive.agents.conversation.collaberative
: Collaborative work management
haive.agents.conversation.social_media
: Social media simulation platform
haive.agents.simple
: SimpleAgent for conversation participants
haive.agents.react
: ReactAgent for intelligent moderation
Submodules¶
Classes¶
Configuration specific to collaborative conversations. |
|
Configuration for conversation agents. |
|
Protocol for agents that can participate in conversations. |
|
Configuration specific to debate conversations. |
Functions¶
|
Create a collaborative conversation for team tasks. |
|
Create a conversation agent of the specified type. |
|
Create a structured debate conversation. |
Get list of available conversation types. |
|
|
Validate that participants meet conversation requirements. |
Package Contents¶
- class agents.conversation.CollaborativeConfig¶
Bases:
ConversationConfig
Configuration specific to collaborative conversations.
Initialize self. See help(type(self)) for accurate signature.
- class agents.conversation.ConversationConfig¶
Bases:
typing_extensions.TypedDict
Configuration for conversation agents.
Initialize self. See help(type(self)) for accurate signature.
- class agents.conversation.ConversationParticipant¶
Bases:
Protocol
Protocol for agents that can participate in conversations.
- async arun(input_data)¶
Run the agent with input data.
- Parameters:
input_data (Any)
- Return type:
Any
- get_role()¶
Get the participant’s role in the conversation.
- Return type:
ParticipantRole
- class agents.conversation.DebateConfig¶
Bases:
ConversationConfig
Configuration specific to debate conversations.
Initialize self. See help(type(self)) for accurate signature.
- agents.conversation.create_collaboration(task, participants, deliverables=None, config=None)¶
Create a collaborative conversation for team tasks.
- Parameters:
task (str) – Task description for the collaboration
participants (dict[str, ConversationParticipant]) – Dictionary mapping roles to participant agents
deliverables (list[str] | None) – Optional list of expected deliverables
config (CollaborativeConfig | None) – Optional collaboration configuration
- Returns:
Configured collaborative conversation
- Return type:
haive.agents.conversation.collaberative.agent.CollaborativeConversation
Examples
Software development team:
collaboration = create_collaboration( task="Design a new mobile app", participants={ "designer": ui_designer, "engineer": developer, "product_manager": pm }, deliverables=["mockup", "specs", "timeline"] )
Research team:
collaboration = create_collaboration( task="Analyze market trends", participants={ "analyst": data_analyst, "researcher": market_researcher, "strategist": business_strategist }, config={"progress_tracking": True} )
- agents.conversation.create_conversation(conversation_type, participants, topic, config=None, **kwargs)¶
Create a conversation agent of the specified type.
- Parameters:
conversation_type (ConversationType) – Type of conversation to create
participants (list[ConversationParticipant]) – List of agents to participate in the conversation
topic (str) – Topic or subject of the conversation
config (ConversationConfig | None) – Optional configuration for the conversation
**kwargs (Any) – Additional keyword arguments specific to the conversation type
- Returns:
Configured conversation agent
- Return type:
haive.agents.conversation.base.agent.BaseConversationAgent
Examples
Round robin conversation:
conversation = create_conversation( "round_robin", participants=[alice, bob, charlie], topic="Future of AI", config={"max_turns": 10} )
Debate conversation:
debate = create_conversation( "debate", participants=[pro_agent, con_agent], topic="Should AI be regulated?", judge_agent=judge_agent, rounds=3 )
- agents.conversation.create_debate(topic, pro_agents, con_agents, judge_agent=None, rounds=3, config=None)¶
Create a structured debate conversation.
- Parameters:
topic (str) – Topic to debate
pro_agents (list[ConversationParticipant]) – Agents arguing for the topic
con_agents (list[ConversationParticipant]) – Agents arguing against the topic
judge_agent (ConversationParticipant | None) – Optional judge agent to score the debate
rounds (int) – Number of debate rounds
config (DebateConfig | None) – Optional debate configuration
- Returns:
Configured debate conversation
- Return type:
haive.agents.conversation.debate.agent.DebateConversation
Examples
Simple debate:
debate = create_debate( topic="Should AI be regulated?", pro_agents=[regulatory_expert], con_agents=[tech_advocate], judge_agent=neutral_judge )
Multi-participant debate:
debate = create_debate( topic="Climate change solutions", pro_agents=[scientist1, activist], con_agents=[economist, skeptic], rounds=5, config={"time_per_round": 300} )
- agents.conversation.get_conversation_types()¶
Get list of available conversation types.
- Returns:
List of available conversation type strings
- Return type:
list[ConversationType]
- agents.conversation.validate_participants(participants, min_participants=2, max_participants=None)¶
Validate that participants meet conversation requirements.
- Parameters:
participants (list[ConversationParticipant]) – List of participant agents
min_participants (int) – Minimum number of participants required
max_participants (int | None) – Maximum number of participants allowed
- Returns:
True if participants are valid, False otherwise
- Raises:
ValueError – If validation fails with specific error details
- Return type: