microsoft/graphrag · error · ValueError

The sum of community_prop and text_unit_prop should not exce

Error message

The sum of community_prop and text_unit_prop should not exceed 1.

What it means

LocalSearch's mixed context builder allocates context budget between community data and text units using community_prop and text_unit_prop. Their sum must not exceed 1 (they are fractions of the total budget); if community_prop + text_unit_prop > 1, build_context raises this ValueError immediately.

Source

Thrown at packages/graphrag/graphrag/query/structured_search/local_search/mixed_context.py:129

        min_community_rank: int = 0,
        community_context_name: str = "Reports",
        column_delimiter: str = "|",
        **kwargs: dict[str, Any],
    ) -> ContextBuilderResult:
        """
        Build data context for local search prompt.

        Build a context by combining community reports and entity/relationship/covariate tables, and text units using a predefined ratio set by summary_prop.
        """
        if include_entity_names is None:
            include_entity_names = []
        if exclude_entity_names is None:
            exclude_entity_names = []
        if community_prop + text_unit_prop > 1:
            value_error = (
                "The sum of community_prop and text_unit_prop should not exceed 1."
            )
            raise ValueError(value_error)

        # map user query to entities
        # if there is conversation history, attached the previous user questions to the current query
        if conversation_history:
            pre_user_questions = "\n".join(
                conversation_history.get_user_turns(conversation_history_max_turns)
            )
            query = f"{query}\n{pre_user_questions}"

        selected_entities = map_query_to_entities(
            query=query,
            text_embedding_vectorstore=self.entity_text_embeddings,
            text_embedder=self.text_embedder,
            all_entities_dict=self.entities,
            embedding_vectorstore_key=self.embedding_vectorstore_key,
            include_entity_names=include_entity_names,
            exclude_entity_names=exclude_entity_names,
            k=top_k_mapped_entities,

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Lower one or both values so community_prop + text_unit_prop <= 1 (e.g. defaults 0.15 + 0.75 = 0.9)
  2. Fix settings.yaml local_search.community_prop and local_search.text_unit_prop to sum to at most 1
  3. If constructing MixedContext/LocalSearch in code, validate the props against your constants before instantiating

Example fix

# before
search = LocalSearch(
    ...,
    context_builder=...
)  # settings.yaml: community_prop: 0.3, text_unit_prop: 0.9

# after
# settings.yaml
local_search:
  community_prop: 0.3
  text_unit_prop: 0.7
Defensive patterns

Strategy: validation

Validate before calling

community_prop, text_unit_prop = 0.3, 0.7
assert community_prop + text_unit_prop <= 1, "community_prop + text_unit_prop must be <= 1"
search = LocalSearch(..., community_prop=community_prop, text_unit_prop=text_unit_prop)

Type guard

def valid_props(community_prop: float, text_unit_prop: float) -> bool:
    return 0 <= community_prop <= 1 and 0 <= text_unit_prop <= 1 and community_prop + text_unit_prop <= 1

Prevention

When it happens

Trigger: Calling LocalSearch.search/stream_search or MixedContext.build_context with community_prop + text_unit_prop > 1, e.g. community_prop=0.3 and text_unit_prop=0.9, either via constructor arguments or settings.yaml (local_search.community_prop / local_search.text_unit_prop).

Common situations: Tuning local_search settings in settings.yaml and raising one proportion without lowering the other, copying example configs with incompatible values, or passing both props programmatically with a typo (e.g. 0.8 + 0.5).

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27). Data as JSON: /api/errors/f89f26d1e1083c80. Report an issue: GitHub.