Do you need to file an issue?
Describe the bug
In graphrag/query/context_builder/dynamic_community_selection.py, lines 131-132 read:
for child in self.communities[community].children: # child is int
if child in self.reports: # self.reports keys are str
Because children holds integers and self.reports is keyed by strings, the membership test always fails.
As a result, IDs that should be selected as child communities are missed, and the exploration of the next community level is never executed.
Steps to reproduce
Execute global_search with dynamic_community_selection=True using a knowledge graph where the highest community_level is 1 or higher.
Expected Behavior
Expected Behavior
Child community IDs should match the type used in self.reports, allowing them to be evaluated and, if relevant, included in the result.
Actual Behavior
if child in self.reports is always False; all child communities are skipped, so the algorithm never descends to the next level.
GraphRAG Config Used
Logs and screenshots
This is the current behavior when a query is issued:
The message cannot find community is displayed, and only 10 out of 5,586 communities are referenced.

This is the behavior after a simple fix was applied:
309 out of 5,586 communities are now referenced when a query is issued.
Note: The threshold is set to 2.

Fixed Code:
for child in self.communities[community].children:
if str(child) in self.reports:
communities_to_rate.append(str(child))
Additional Information
- GraphRAG Version: v2.4.0
- Operating System: Windows 11
- Python Version: 3.12.11
- Related Issues: Nothing
Do you need to file an issue?
Describe the bug
In graphrag/query/context_builder/dynamic_community_selection.py, lines 131-132 read:
Because children holds integers and self.reports is keyed by strings, the membership test always fails.
As a result, IDs that should be selected as child communities are missed, and the exploration of the next community level is never executed.
Steps to reproduce
Execute
global_searchwithdynamic_community_selection=Trueusing a knowledge graph where the highestcommunity_levelis 1 or higher.Expected Behavior
Expected Behavior
Child community IDs should match the type used in
self.reports, allowing them to be evaluated and, if relevant, included in the result.Actual Behavior
if child in self.reportsis alwaysFalse; all child communities are skipped, so the algorithm never descends to the next level.GraphRAG Config Used
# Paste your config hereLogs and screenshots
This is the current behavior when a query is issued:

The message cannot find community is displayed, and only 10 out of 5,586 communities are referenced.
This is the behavior after a simple fix was applied:

309 out of 5,586 communities are now referenced when a query is issued.
Note: The
thresholdis set to 2.Fixed Code:
Additional Information