Principle:Spcl Graph of thoughts Thought Aggregation
| Knowledge Sources | |
|---|---|
| Domains | Graph_Reasoning, Thought_Operations |
| Last Updated | 2026-02-14 |
| Implemented By | Implementation:Spcl_Graph_of_thoughts_Aggregate_Operation |
Overview
Operation pattern that merges multiple thought states into a unified state by prompting a language model to combine results.
Description
The Aggregate operation is a core component of the Graph of Thoughts (GoT) framework that takes thoughts from multiple predecessor operations, generates an aggregation prompt containing all of their states, and produces one or more merged thought(s). This operation is what enables the "merge" step in GoT's fundamental decompose-solve-merge pattern.
During execution, the Aggregate operation collects all predecessor thoughts and constructs a base state by merging individual thought states in order of score (lowest score first, so higher-scored thoughts overwrite lower-scored ones). It then passes the list of all predecessor thought states to the Prompter's aggregation_prompt method, which crafts a prompt instructing the language model to combine the results. The LM's response is parsed by the Parser's parse_aggregation_answer method to produce the final merged state(s).
Key characteristics:
- Collects thoughts from all predecessor operations
- Builds a base state by layering predecessor states sorted by score (ascending), so that higher-scoring states take precedence
- Prompts the LM with all predecessor states simultaneously for synthesis
- Supports producing multiple merged outputs via the num_responses parameter
- Parsed results can be a single dict or a list of dicts, each producing a new thought
- If no predecessor thoughts exist (e.g., predecessors produced empty results), the operation returns without creating any thoughts
Usage
Use the Aggregate operation when you need to combine results from multiple parallel reasoning branches into a unified answer. This is the standard merge step in GoT topologies where a problem has been decomposed into sub-problems, each solved independently, and the solutions must now be recombined. Typical examples include:
- Sorting: Merging independently sorted sublists back into a single sorted list
- Set intersection: Combining partial intersection results from subsets
- Document merging: Synthesizing summaries from independently processed document sections
The Aggregate operation requires at least one predecessor and relies on the Prompter and Parser to define domain-specific aggregation logic.
Theoretical Basis
The Aggregate operation implements the convergence (or merge) step in graph-based reasoning, as described in the GoT paper. In contrast to Chain-of-Thought (CoT) and Tree-of-Thought (ToT) approaches, which are limited to sequential or branching reasoning patterns, GoT introduces the ability to merge reasoning branches back together. This convergence capability is what gives GoT its graph structure (as opposed to a chain or tree).
Formally, in the GoT framework, an Aggregate operation corresponds to a vertex in the Graph of Operations (GoO) with multiple incoming edges. Each incoming edge carries a thought from a different predecessor operation. The aggregation vertex applies a transformation T that maps multiple input thoughts to one or more output thoughts:
T: (t_1, t_2, ..., t_k) -> (t'_1, ..., t'_m)
where t_i are the input thoughts from predecessors and t'_j are the merged output thoughts. The transformation is implemented via the language model, which is prompted to synthesize the inputs.
This pattern directly enables the divide-and-conquer strategy: decompose a problem via Generate, solve sub-problems in parallel branches, and then use Aggregate to recombine the solutions. The paper demonstrates that this approach outperforms linear reasoning (IO, CoT) and branching-only reasoning (ToT) on tasks like sorting and set intersection.
Code Reference
The Aggregate principle is implemented in the Aggregate class:
- Source file:
graph_of_thoughts/operations/operations.py, Lines 536-610 - Class:
Aggregate(Operation) - Operation type:
OperationType.aggregate
Related Pages
- Implementation:Spcl_Graph_of_thoughts_Aggregate_Operation - Concrete implementation of this principle
- Principle:Spcl_Graph_of_thoughts_Thought_Selection - Selector operation used to partition thoughts before aggregation
- Principle:Spcl_Graph_of_thoughts_Best_N_Selection - KeepBestN operation often used before aggregation to filter best candidates
- Workflow:Spcl_Graph_of_thoughts_GoT_Sorting_Pipeline - Sorting workflow that uses Aggregate for merge step