Overview
The Hierarchical Structured Communication Framework implements the “Talk Structurally, Act Hierarchically” approach for LLM multi-agent systems, based on the research paper arXiv:2502.11098. It provides structured communication protocols with specialized agent classes for content generation, evaluation, refinement, and supervision.Installation
Key Components
Agent Classes
HierarchicalStructuredCommunicationGenerator- Creates initial contentHierarchicalStructuredCommunicationEvaluator- Evaluates content qualityHierarchicalStructuredCommunicationRefiner- Improves content based on feedbackHierarchicalStructuredCommunicationSupervisor- Coordinates workflow
Main Framework
HierarchicalStructuredCommunicationFramework- Main orchestrator class
Attributes
str
default:"HierarchicalStructuredCommunicationFramework"
Name of the framework instance
Optional[Union[Agent, Callable, Any]]
default:"None"
Main supervisor agent that coordinates the workflow. If not provided, a default
Agent supervisor is created automatically.Optional[List[Union[Agent, Callable, Any]]]
default:"None"
List of generator agents for creating initial content. If not provided, a single default generator agent is created automatically.
Optional[List[Union[Agent, Callable, Any]]]
default:"None"
List of evaluator agents for assessing content quality. If not provided (and
enable_hierarchical_evaluation=True), a single default evaluator agent is created automatically.Optional[List[Union[Agent, Callable, Any]]]
default:"None"
List of refiner agents for improving content based on feedback. If not provided, a single default refiner agent is created automatically.
Optional[Union[Agent, Callable, Any]]
default:"None"
Dedicated supervisor that coordinates the hierarchical evaluation phase. Created automatically if not provided.
int
default:"3"
Maximum number of refinement loops
OutputType
default:"dict-all-except-first"
Format applied to the conversation history.
str
default:"Supervisor"
Display name for the main supervisor agent.
str
default:"EvaluationSupervisor"
Display name for the evaluation supervisor agent.
bool
default:"True"
Enable the structured communication protocol with Message (M_ij), Background (B_ij), and Intermediate Output (I_ij)
bool
default:"True"
Enable hierarchical evaluation with supervisor coordination
Enable shared memory between agents
str
default:"gpt-5.4"
LLM model name to use for the agents
bool
default:"False"
Enable verbose logging
bool
default:"False"
Route agent calls through a local Ollama server instead of a hosted provider.
str
default:"http://localhost:11434/v1"
Base URL for the Ollama server when
use_ollama=True.str
default:"ollama"
API key sent to the Ollama server when
use_ollama=True.Methods
run()
Execute the complete workflow for a given task, looping up tomax_loops times (set at construction).
task(str): The task to executeimg(str, optional): Optional image input
final_result, total_loops, conversation_history, evaluation_results, and intermediate_outputs
run() does not accept a max_loops override — the number of refinement loops is fixed by the max_loops value passed to the constructor.step()
Execute a single workflow step (generate, evaluate, refine).task(str): The task to execute for one stepimg(str, optional): Optional image input
generator_result, evaluation_results, refined_result, and conversation_history (or an error key on failure)
send_structured_message()
Send a structured communication message between agents, following the Message (M_ij) / Background (B_ij) / Intermediate Output (I_ij) protocol.sender(str): Name of the sending agentrecipient(str): Name of the receiving agentmessage(str): Specific task message (M_ij)background(str, optional): Background context (B_ij)intermediate_output(str, optional): Intermediate output (I_ij)
StructuredMessage that was appended to conversation_history
run_hierarchical_evaluation()
Run the hierarchical evaluation system with supervisor coordination.content(str): Content to evaluateevaluation_criteria(List[str], optional): Criteria to evaluate against. Defaults to["accuracy", "completeness", "clarity", "relevance"].
EvaluationResult objects, one per evaluator
Usage Examples
Quick Start
Basic Usage with Default Supervisor
Advanced Configuration
How It Works
The framework operates through a structured multi-phase workflow:- Generation Phase: Generator agents create initial content based on the task
- Evaluation Phase: Evaluator agents assess the quality of generated content using structured communication protocols
- Refinement Phase: Refiner agents improve content based on evaluation feedback
- Supervision: The supervisor agent coordinates the entire workflow, deciding when to iterate or finalize
- Iteration: Steps 1-4 repeat up to
max_loopstimes until quality thresholds are met
Structured Communication Protocol
The framework uses a formal communication protocol with three components:- Message (M_ij): Direct communication between agents
- Background (B_ij): Contextual information shared between agents
- Intermediate Output (I_ij): Partial results passed between workflow stages
Features
- Structured Communication: Formal protocol for inter-agent messaging
- Hierarchical Evaluation: Multi-level quality assessment with supervisor oversight
- Iterative Refinement: Content improves through generate-evaluate-refine loops
- Specialized Agents: Purpose-built agent classes for each workflow role
- Configurable: Flexible configuration for communication, evaluation, and memory
- Shared Memory: Optional shared memory between agents for context retention