graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

Label Propagation Lacks Max Iteration Cap, Risking Infinite Loop on Non-Converging Graphs

Open StephenBadger opened this issue 7 months ago • 4 comments

In graphiti_core/utils/maintenance/community_operations.py, the label_propagation function performs iterative community detection based on neighbor voting.

However, there is no hard limit on the number of iterations, and the loop is governed only by a convergence check (no_change).

If convergence is not reached — for example, in graphs with oscillating or ambiguous neighbor relationships — the loop may never terminate.

In my setup, where I am using Graphiti MCP to be the memory bank of an AI Agent for coding, while doing the original input of my code structure, the I kept getting this issue, which caused me to debug and find the underlying. I fixed it locally and want to share.

IF someone can better explain why this occurs, eg the lack of convergences, I'd appreciate the education.

Current Behavior:

  • label_propagation uses while True: and only exits when no_change is True.
  • There is no safeguard like a maximum iteration count.
  • In cases where node community assignments oscillate or do not stabilize (e.g., highly similar graphs), the function will loop indefinitely, causing server stalls and high CPU usage.

while True:
    no_change = True
    new_community_map: dict[str, int] = {}

    # community assignment logic...

    if no_change:
        break

    community_map = new_community_map
  • No iteration counter is present.
  • No maximum iteration limit is checked.

Expected Behavior:

  • There should be a maximum number of iterations, after which the function forces an exit even if full convergence has not been achieved.
  • This would ensure robustness even on difficult or ambiguous graphs.

Suggested Minimal Fix:

  • Introduce an iteration counter.
  • Add a check:
 if iteration >= MAX_PROPAGATION_ITERATIONS:
    break
  • (Optionally) Log a warning if forced to exit without convergence.

Impact:

  • Server can lock up under relatively small graphs (e.g., ~100 nodes) if the graph structure resists convergence.
  • Especially common when nodes and their relationships are similar or repetitive.
  • Results in unresponsive behavior and resource exhaustion.

Example log output from non converging labels

mcp_server-graphiti-mcp-1  | 2025-04-26 19:16:58,983 - graphiti_core.utils.maintenance.community_operations - INFO - 🧩 Label snapshot: {'iteration': 1, 'changed': 59/96 (61.5%), 'sample_labels': {'fbba39c6-736f-4478-a979-9eaaeacd2d98': 25, 'fac1503c-8b9a-4245-9da6-83f553281dfe': 58, 'f9bbd5ba-6e17-444f-bfa0-dd76ed3f4857': 92, 'f7086aa6-f645-43ab-a379-beb80a77a4b2': 24, 'f43d711b-133a-4e3c-bd34-0cbcff14b88e': 11, 'f2684a5c-27fd-4964-99fe-bd9ba92bfdda': 24, 'edf2aad7-2ce6-44be-a9e3-109f4c5a9a79': 94, 'e4fe14b7-0c83-43da-af59-fcc3a7fc902f': 42, 'e0b3f6a9-1309-451a-a63d-b49509a1d483': 58, 'dd4cb3a0-545e-4a65-82b9-e2a9f0e22a9f': 63, 'db8c7bca-123f-4a25-9121-cff6a5f52b8f': 58, 'db50fbe2-bbab-41b1-8ef9-e4045c34f70c': 11, 'db1295af-35f6-485b-a0b2-a2c609b16029': 27, 'd9f824f0-c2d3-4fdb-a8d0-604a80856601': 63, 'd54aeec0-a8d8-4376-8afb-984f333bcd43': 58, 'd231a45b-f8a4-46f0-9bd9-d2a33c006e8a': 24, 'cd0736ee-469e-4059-83b0-3b0462c5600f': 71, 'cb1c8bf3-711a-441f-b73c-4543702a866b': 63, 'c7f07d64-f9e0-488a-b3e1-54dc9b09fb72': 25, 'c7b708ed-d790-4c34-9e3c-850fb81d6924': 24, 'c4692b54-cd7c-46e3-9b91-6ba933fd737b': 58, 'bfe03e58-31ca-4ad6-87b6-b6ea98fff91e': 27, 'bf1fbf05-d064-4b05-b13e-a0880b4979bc': 58, 'bec1725f-1c01-4d1e-9ddb-625965308e7f': 58, 'bbdf046f-2a3b-431f-9f61-3f78707a7d0f': 24, 'b90a34d1-78b3-489f-9261-e8d79f09db35': 52, 'b887f93d-5984-44c0-9817-e04cacfed8ab': 41, 'b7f1aac7-aa3e-4764-b3e2-5262973ea60b': 86, 'b5a85629-3338-4619-83b1-e268597a49af': 56, 'b328848e-18d1-4fbd-8f7f-4a463e1b3cbb': 63, 'b1ac86f2-9fc1-40b1-ada3-58f98d050e7e': 58, 'b16c5c44-99f7-436a-925f-491b5d015037': 41, 'b021c28c-898d-4c6b-978c-3cb838173b6f': 95, 'a0bf2932-7c2b-4ee6-a26a-a52daec242f2': 71, 'a05d8f64-c12b-4f5a-9ddf-5ab983cbf589': 34, 'a025eb4c-42d4-4122-8506-a3dc9ee04f6c': 71, '9d4476b9-6f08-4ac2-aaec-a5905da91f59': 36, '9c23d210-8b9a-4dad-ad45-724265c5ecd0': 71, '9a1602eb-3ab4-44d3-b106-54aa9093e789': 71, '991549db-c7a7-4b6d-a2ae-abc7a6480f8a': 39, '97e4def0-2f4c-46a8-900e-638ab1141696': 56, '97dfd97f-224d-469e-8e78-faaa0876f148': 92, '936cdc4f-1f52-4fe0-89f5-86381fefd895': 92, '9344a279-12a4-4d02-811a-61153d7ba0c5': 58, '8c337caf-808e-4865-bd04-6eedd79b103f': 71, '8bf223bf-6dfd-40ec-a824-67f6a5799bfd': 45, '89777fbf-18ff-4920-aa1b-c6d0ab76c444': 50, '8518597e-e051-4233-b146-3f4e8033a9f0': 58, '8141143f-e465-4e92-8bb8-8fd3bc2942d9': 71, '8095aabc-fa02-4156-b9ec-7b18973ff4fb': 63}}
mcp_server-graphiti-mcp-1  | 2025-04-26 19:16:58,984 - graphiti_core.utils.maintenance.community_operations - INFO - 🧩 Label snapshot: {'iteration': 5, 'changed': 18/96 (18.8%), 'sample_labels': {'fbba39c6-736f-4478-a979-9eaaeacd2d98': 52, 'fac1503c-8b9a-4245-9da6-83f553281dfe': 58, 'f9bbd5ba-6e17-444f-bfa0-dd76ed3f4857': 92, 'f7086aa6-f645-43ab-a379-beb80a77a4b2': 24, 'f43d711b-133a-4e3c-bd34-0cbcff14b88e': 11, 'f2684a5c-27fd-4964-99fe-bd9ba92bfdda': 24, 'edf2aad7-2ce6-44be-a9e3-109f4c5a9a79': 94, 'e4fe14b7-0c83-43da-af59-fcc3a7fc902f': 95, 'e0b3f6a9-1309-451a-a63d-b49509a1d483': 58, 'dd4cb3a0-545e-4a65-82b9-e2a9f0e22a9f': 63, 'db8c7bca-123f-4a25-9121-cff6a5f52b8f': 58, 'db50fbe2-bbab-41b1-8ef9-e4045c34f70c': 11, 'db1295af-35f6-485b-a0b2-a2c609b16029': 92, 'd9f824f0-c2d3-4fdb-a8d0-604a80856601': 63, 'd54aeec0-a8d8-4376-8afb-984f333bcd43': 58, 'd231a45b-f8a4-46f0-9bd9-d2a33c006e8a': 24, 'cd0736ee-469e-4059-83b0-3b0462c5600f': 71, 'cb1c8bf3-711a-441f-b73c-4543702a866b': 92, 'c7f07d64-f9e0-488a-b3e1-54dc9b09fb72': 52, 'c7b708ed-d790-4c34-9e3c-850fb81d6924': 24, 'c4692b54-cd7c-46e3-9b91-6ba933fd737b': 58, 'bfe03e58-31ca-4ad6-87b6-b6ea98fff91e': 92, 'bf1fbf05-d064-4b05-b13e-a0880b4979bc': 58, 'bec1725f-1c01-4d1e-9ddb-625965308e7f': 58, 'bbdf046f-2a3b-431f-9f61-3f78707a7d0f': 24, 'b90a34d1-78b3-489f-9261-e8d79f09db35': 52, 'b887f93d-5984-44c0-9817-e04cacfed8ab': 92, 'b7f1aac7-aa3e-4764-b3e2-5262973ea60b': 92, 'b5a85629-3338-4619-83b1-e268597a49af': 92, 'b328848e-18d1-4fbd-8f7f-4a463e1b3cbb': 63, 'b1ac86f2-9fc1-40b1-ada3-58f98d050e7e': 58, 'b16c5c44-99f7-436a-925f-491b5d015037': 92, 'b021c28c-898d-4c6b-978c-3cb838173b6f': 95, 'a0bf2932-7c2b-4ee6-a26a-a52daec242f2': 83, 'a05d8f64-c12b-4f5a-9ddf-5ab983cbf589': 95, 'a025eb4c-42d4-4122-8506-a3dc9ee04f6c': 71, '9d4476b9-6f08-4ac2-aaec-a5905da91f59': 36, '9c23d210-8b9a-4dad-ad45-724265c5ecd0': 95, '9a1602eb-3ab4-44d3-b106-54aa9093e789': 83, '991549db-c7a7-4b6d-a2ae-abc7a6480f8a': 92, '97e4def0-2f4c-46a8-900e-638ab1141696': 92, '97dfd97f-224d-469e-8e78-faaa0876f148': 92, '936cdc4f-1f52-4fe0-89f5-86381fefd895': 92, '9344a279-12a4-4d02-811a-61153d7ba0c5': 58, '8c337caf-808e-4865-bd04-6eedd79b103f': 71, '8bf223bf-6dfd-40ec-a824-67f6a5799bfd': 95, '89777fbf-18ff-4920-aa1b-c6d0ab76c444': 73, '8518597e-e051-4233-b146-3f4e8033a9f0': 58, '8141143f-e465-4e92-8bb8-8fd3bc2942d9': 71, '8095aabc-fa02-4156-b9ec-7b18973ff4fb': 63}}
mcp_server-graphiti-mcp-1  | 2025-04-26 19:16:58,985 - graphiti_core.utils.maintenance.community_operations - INFO - 🧩 Label snapshot: {'iteration': 10, 'changed': 16/96 (16.7%), 'sample_labels': {'fbba39c6-736f-4478-a979-9eaaeacd2d98': 52, 'fac1503c-8b9a-4245-9da6-83f553281dfe': 58, 'f9bbd5ba-6e17-444f-bfa0-dd76ed3f4857': 92, 'f7086aa6-f645-43ab-a379-beb80a77a4b2': 24, 'f43d711b-133a-4e3c-bd34-0cbcff14b88e': 11, 'f2684a5c-27fd-4964-99fe-bd9ba92bfdda': 24, 'edf2aad7-2ce6-44be-a9e3-109f4c5a9a79': 71, 'e4fe14b7-0c83-43da-af59-fcc3a7fc902f': 95, 'e0b3f6a9-1309-451a-a63d-b49509a1d483': 58, 'dd4cb3a0-545e-4a65-82b9-e2a9f0e22a9f': 63, 'db8c7bca-123f-4a25-9121-cff6a5f52b8f': 58, 'db50fbe2-bbab-41b1-8ef9-e4045c34f70c': 11, 'db1295af-35f6-485b-a0b2-a2c609b16029': 92, 'd9f824f0-c2d3-4fdb-a8d0-604a80856601': 63, 'd54aeec0-a8d8-4376-8afb-984f333bcd43': 58, 'd231a45b-f8a4-46f0-9bd9-d2a33c006e8a': 24, 'cd0736ee-469e-4059-83b0-3b0462c5600f': 95, 'cb1c8bf3-711a-441f-b73c-4543702a866b': 92, 'c7f07d64-f9e0-488a-b3e1-54dc9b09fb72': 52, 'c7b708ed-d790-4c34-9e3c-850fb81d6924': 24, 'c4692b54-cd7c-46e3-9b91-6ba933fd737b': 58, 'bfe03e58-31ca-4ad6-87b6-b6ea98fff91e': 92, 'bf1fbf05-d064-4b05-b13e-a0880b4979bc': 58, 'bec1725f-1c01-4d1e-9ddb-625965308e7f': 58, 'bbdf046f-2a3b-431f-9f61-3f78707a7d0f': 24, 'b90a34d1-78b3-489f-9261-e8d79f09db35': 25, 'b887f93d-5984-44c0-9817-e04cacfed8ab': 92, 'b7f1aac7-aa3e-4764-b3e2-5262973ea60b': 92, 'b5a85629-3338-4619-83b1-e268597a49af': 92, 'b328848e-18d1-4fbd-8f7f-4a463e1b3cbb': 63, 'b1ac86f2-9fc1-40b1-ada3-58f98d050e7e': 58, 'b16c5c44-99f7-436a-925f-491b5d015037': 92, 'b021c28c-898d-4c6b-978c-3cb838173b6f': 95, 'a0bf2932-7c2b-4ee6-a26a-a52daec242f2': 83, 'a05d8f64-c12b-4f5a-9ddf-5ab983cbf589': 95, 'a025eb4c-42d4-4122-8506-a3dc9ee04f6c': 83, '9d4476b9-6f08-4ac2-aaec-a5905da91f59': 36, '9c23d210-8b9a-4dad-ad45-724265c5ecd0': 95, '9a1602eb-3ab4-44d3-b106-54aa9093e789': 83, '991549db-c7a7-4b6d-a2ae-abc7a6480f8a': 92, '97e4def0-2f4c-46a8-900e-638ab1141696': 92, '97dfd97f-224d-469e-8e78-faaa0876f148': 92, '936cdc4f-1f52-4fe0-89f5-86381fefd895': 95, '9344a279-12a4-4d02-811a-61153d7ba0c5': 58, '8c337caf-808e-4865-bd04-6eedd79b103f': 94, '8bf223bf-6dfd-40ec-a824-67f6a5799bfd': 92, '89777fbf-18ff-4920-aa1b-c6d0ab76c444': 54, '8518597e-e051-4233-b146-3f4e8033a9f0': 58, '8141143f-e465-4e92-8bb8-8fd3bc2942d9': 94, '8095aabc-fa02-4156-b9ec-7b18973ff4fb': 63}}
mcp_server-graphiti-mcp-1  | 2025-04-26 19:16:58,986 - graphiti_core.utils.maintenance.community_operations - INFO - 🧩 Label snapshot: {'iteration': 15, 'changed': 16/96 (16.7%), 'sample_labels': {'fbba39c6-736f-4478-a979-9eaaeacd2d98': 52, 'fac1503c-8b9a-4245-9da6-83f553281dfe': 58, 'f9bbd5ba-6e17-444f-bfa0-dd76ed3f4857': 92, 'f7086aa6-f645-43ab-a379-beb80a77a4b2': 24, 'f43d711b-133a-4e3c-bd34-0cbcff14b88e': 11, 'f2684a5c-27fd-4964-99fe-bd9ba92bfdda': 24, 'edf2aad7-2ce6-44be-a9e3-109f4c5a9a79': 94, 'e4fe14b7-0c83-43da-af59-fcc3a7fc902f': 95, 'e0b3f6a9-1309-451a-a63d-b49509a1d483': 58, 'dd4cb3a0-545e-4a65-82b9-e2a9f0e22a9f': 63, 'db8c7bca-123f-4a25-9121-cff6a5f52b8f': 58, 'db50fbe2-bbab-41b1-8ef9-e4045c34f70c': 11, 'db1295af-35f6-485b-a0b2-a2c609b16029': 92, 'd9f824f0-c2d3-4fdb-a8d0-604a80856601': 63, 'd54aeec0-a8d8-4376-8afb-984f333bcd43': 58, 'd231a45b-f8a4-46f0-9bd9-d2a33c006e8a': 24, 'cd0736ee-469e-4059-83b0-3b0462c5600f': 71, 'cb1c8bf3-711a-441f-b73c-4543702a866b': 92, 'c7f07d64-f9e0-488a-b3e1-54dc9b09fb72': 52, 'c7b708ed-d790-4c34-9e3c-850fb81d6924': 24, 'c4692b54-cd7c-46e3-9b91-6ba933fd737b': 58, 'bfe03e58-31ca-4ad6-87b6-b6ea98fff91e': 92, 'bf1fbf05-d064-4b05-b13e-a0880b4979bc': 58, 'bec1725f-1c01-4d1e-9ddb-625965308e7f': 58, 'bbdf046f-2a3b-431f-9f61-3f78707a7d0f': 24, 'b90a34d1-78b3-489f-9261-e8d79f09db35': 52, 'b887f93d-5984-44c0-9817-e04cacfed8ab': 92, 'b7f1aac7-aa3e-4764-b3e2-5262973ea60b': 92, 'b5a85629-3338-4619-83b1-e268597a49af': 92, 'b328848e-18d1-4fbd-8f7f-4a463e1b3cbb': 63, 'b1ac86f2-9fc1-40b1-ada3-58f98d050e7e': 58, 'b16c5c44-99f7-436a-925f-491b5d015037': 92, 'b021c28c-898d-4c6b-978c-3cb838173b6f': 95, 'a0bf2932-7c2b-4ee6-a26a-a52daec242f2': 83, 'a05d8f64-c12b-4f5a-9ddf-5ab983cbf589': 95, 'a025eb4c-42d4-4122-8506-a3dc9ee04f6c': 71, '9d4476b9-6f08-4ac2-aaec-a5905da91f59': 36, '9c23d210-8b9a-4dad-ad45-724265c5ecd0': 95, '9a1602eb-3ab4-44d3-b106-54aa9093e789': 83, '991549db-c7a7-4b6d-a2ae-abc7a6480f8a': 92, '97e4def0-2f4c-46a8-900e-638ab1141696': 92, '97dfd97f-224d-469e-8e78-faaa0876f148': 92, '936cdc4f-1f52-4fe0-89f5-86381fefd895': 92, '9344a279-12a4-4d02-811a-61153d7ba0c5': 58, '8c337caf-808e-4865-bd04-6eedd79b103f': 71, '8bf223bf-6dfd-40ec-a824-67f6a5799bfd': 95, '89777fbf-18ff-4920-aa1b-c6d0ab76c444': 73, '8518597e-e051-4233-b146-3f4e8033a9f0': 58, '8141143f-e465-4e92-8bb8-8fd3bc2942d9': 71, '8095aabc-fa02-4156-b9ec-7b18973ff4fb': 63}}
mcp_server-graphiti-mcp-1  | 2025-04-26 19:16:58,987 - graphiti_core.utils.maintenance.community_operations - INFO - 🧩 Label snapshot: {'iteration': 20, 'changed': 16/96 (16.7%), 'sample_labels': {'fbba39c6-736f-4478-a979-9eaaeacd2d98': 52, 'fac1503c-8b9a-4245-9da6-83f553281dfe': 58, 'f9bbd5ba-6e17-444f-bfa0-dd76ed3f4857': 92, 'f7086aa6-f645-43ab-a379-beb80a77a4b2': 24, 'f43d711b-133a-4e3c-bd34-0cbcff14b88e': 11, 'f2684a5c-27fd-4964-99fe-bd9ba92bfdda': 24, 'edf2aad7-2ce6-44be-a9e3-109f4c5a9a79': 71, 'e4fe14b7-0c83-43da-af59-fcc3a7fc902f': 95, 'e0b3f6a9-1309-451a-a63d-b49509a1d483': 58, 'dd4cb3a0-545e-4a65-82b9-e2a9f0e22a9f': 63, 'db8c7bca-123f-4a25-9121-cff6a5f52b8f': 58, 'db50fbe2-bbab-41b1-8ef9-e4045c34f70c': 11, 'db1295af-35f6-485b-a0b2-a2c609b16029': 92, 'd9f824f0-c2d3-4fdb-a8d0-604a80856601': 63, 'd54aeec0-a8d8-4376-8afb-984f333bcd43': 58, 'd231a45b-f8a4-46f0-9bd9-d2a33c006e8a': 24, 'cd0736ee-469e-4059-83b0-3b0462c5600f': 95, 'cb1c8bf3-711a-441f-b73c-4543702a866b': 92, 'c7f07d64-f9e0-488a-b3e1-54dc9b09fb72': 52, 'c7b708ed-d790-4c34-9e3c-850fb81d6924': 24, 'c4692b54-cd7c-46e3-9b91-6ba933fd737b': 58, 'bfe03e58-31ca-4ad6-87b6-b6ea98fff91e': 92, 'bf1fbf05-d064-4b05-b13e-a0880b4979bc': 58, 'bec1725f-1c01-4d1e-9ddb-625965308e7f': 58, 'bbdf046f-2a3b-431f-9f61-3f78707a7d0f': 24, 'b90a34d1-78b3-489f-9261-e8d79f09db35': 25, 'b887f93d-5984-44c0-9817-e04cacfed8ab': 92, 'b7f1aac7-aa3e-4764-b3e2-5262973ea60b': 92, 'b5a85629-3338-4619-83b1-e268597a49af': 92, 'b328848e-18d1-4fbd-8f7f-4a463e1b3cbb': 63, 'b1ac86f2-9fc1-40b1-ada3-58f98d050e7e': 58, 'b16c5c44-99f7-436a-925f-491b5d015037': 92, 'b021c28c-898d-4c6b-978c-3cb838173b6f': 95, 'a0bf2932-7c2b-4ee6-a26a-a52daec242f2': 83, 'a05d8f64-c12b-4f5a-9ddf-5ab983cbf589': 95, 'a025eb4c-42d4-4122-8506-a3dc9ee04f6c': 83, '9d4476b9-6f08-4ac2-aaec-a5905da91f59': 36, '9c23d210-8b9a-4dad-ad45-724265c5ecd0': 95, '9a1602eb-3ab4-44d3-b106-54aa9093e789': 83, '991549db-c7a7-4b6d-a2ae-abc7a6480f8a': 92, '97e4def0-2f4c-46a8-900e-638ab1141696': 92, '97dfd97f-224d-469e-8e78-faaa0876f148': 92, '936cdc4f-1f52-4fe0-89f5-86381fefd895': 95, '9344a279-12a4-4d02-811a-61153d7ba0c5': 58, '8c337caf-808e-4865-bd04-6eedd79b103f': 94, '8bf223bf-6dfd-40ec-a824-67f6a5799bfd': 92, '89777fbf-18ff-4920-aa1b-c6d0ab76c444': 54, '8518597e-e051-4233-b146-3f4e8033a9f0': 58, '8141143f-e465-4e92-8bb8-8fd3bc2942d9': 94, '8095aabc-fa02-4156-b9ec-7b18973ff4fb': 63}}
mcp_server-graphiti-mcp-1  | 2025-04-26 19:16:58,988 - graphiti_core.utils.maintenance.community_operations - INFO - 🧩 Label snapshot: {'iteration': 25, 'changed': 16/96 (16.7%), 'sample_labels': {'fbba39c6-736f-4478-a979-9eaaeacd2d98': 52, 'fac1503c-8b9a-4245-9da6-83f553281dfe': 58, 'f9bbd5ba-6e17-444f-bfa0-dd76ed3f4857': 92, 'f7086aa6-f645-43ab-a379-beb80a77a4b2': 24, 'f43d711b-133a-4e3c-bd34-0cbcff14b88e': 11, 'f2684a5c-27fd-4964-99fe-bd9ba92bfdda': 24, 'edf2aad7-2ce6-44be-a9e3-109f4c5a9a79': 94, 'e4fe14b7-0c83-43da-af59-fcc3a7fc902f': 95, 'e0b3f6a9-1309-451a-a63d-b49509a1d483': 58, 'dd4cb3a0-545e-4a65-82b9-e2a9f0e22a9f': 63, 'db8c7bca-123f-4a25-9121-cff6a5f52b8f': 58, 'db50fbe2-bbab-41b1-8ef9-e4045c34f70c': 11, 'db1295af-35f6-485b-a0b2-a2c609b16029': 92, 'd9f824f0-c2d3-4fdb-a8d0-604a80856601': 63, 'd54aeec0-a8d8-4376-8afb-984f333bcd43': 58, 'd231a45b-f8a4-46f0-9bd9-d2a33c006e8a': 24, 'cd0736ee-469e-4059-83b0-3b0462c5600f': 71, 'cb1c8bf3-711a-441f-b73c-4543702a866b': 92, 'c7f07d64-f9e0-488a-b3e1-54dc9b09fb72': 52, 'c7b708ed-d790-4c34-9e3c-850fb81d6924': 24, 'c4692b54-cd7c-46e3-9b91-6ba933fd737b': 58, 'bfe03e58-31ca-4ad6-87b6-b6ea98fff91e': 92, 'bf1fbf05-d064-4b05-b13e-a0880b4979bc': 58, 'bec1725f-1c01-4d1e-9ddb-625965308e7f': 58, 'bbdf046f-2a3b-431f-9f61-3f78707a7d0f': 24, 'b90a34d1-78b3-489f-9261-e8d79f09db35': 52, 'b887f93d-5984-44c0-9817-e04cacfed8ab': 92, 'b7f1aac7-aa3e-4764-b3e2-5262973ea60b': 92, 'b5a85629-3338-4619-83b1-e268597a49af': 92, 'b328848e-18d1-4fbd-8f7f-4a463e1b3cbb': 63, 'b1ac86f2-9fc1-40b1-ada3-58f98d050e7e': 58, 'b16c5c44-99f7-436a-925f-491b5d015037': 92, 'b021c28c-898d-4c6b-978c-3cb838173b6f': 95, 'a0bf2932-7c2b-4ee6-a26a-a52daec242f2': 83, 'a05d8f64-c12b-4f5a-9ddf-5ab983cbf589': 95, 'a025eb4c-42d4-4122-8506-a3dc9ee04f6c': 71, '9d4476b9-6f08-4ac2-aaec-a5905da91f59': 36, '9c23d210-8b9a-4dad-ad45-724265c5ecd0': 95, '9a1602eb-3ab4-44d3-b106-54aa9093e789': 83, '991549db-c7a7-4b6d-a2ae-abc7a6480f8a': 92, '97e4def0-2f4c-46a8-900e-638ab1141696': 92, '97dfd97f-224d-469e-8e78-faaa0876f148': 92, '936cdc4f-1f52-4fe0-89f5-86381fefd895': 92, '9344a279-12a4-4d02-811a-61153d7ba0c5': 58, '8c337caf-808e-4865-bd04-6eedd79b103f': 71, '8bf223bf-6dfd-40ec-a824-67f6a5799bfd': 95, '89777fbf-18ff-4920-aa1b-c6d0ab76c444': 73, '8518597e-e051-4233-b146-3f4e8033a9f0': 58, '8141143f-e465-4e92-8bb8-8fd3bc2942d9': 71, '8095aabc-fa02-4156-b9ec-7b18973ff4fb': 63}}
mcp_server-graphiti-mcp-1  | 2025-04-26 19:16:58,988 - graphiti_core.utils.maintenance.community_operations - INFO - 🧩 Label snapshot: {'iteration': 30, 'changed': 16/96 (16.7%), 'sample_labels': {'fbba39c6-736f-4478-a979-9eaaeacd2d98': 52, 'fac1503c-8b9a-4245-9da6-83f553281dfe': 58, 'f9bbd5ba-6e17-444f-bfa0-dd76ed3f4857': 92, 'f7086aa6-f645-43ab-a379-beb80a77a4b2': 24, 'f43d711b-133a-4e3c-bd34-0cbcff14b88e': 11, 'f2684a5c-27fd-4964-99fe-bd9ba92bfdda': 24, 'edf2aad7-2ce6-44be-a9e3-109f4c5a9a79': 71, 'e4fe14b7-0c83-43da-af59-fcc3a7fc902f': 95, 'e0b3f6a9-1309-451a-a63d-b49509a1d483': 58, 'dd4cb3a0-545e-4a65-82b9-e2a9f0e22a9f': 63, 'db8c7bca-123f-4a25-9121-cff6a5f52b8f': 58, 'db50fbe2-bbab-41b1-8ef9-e4045c34f70c': 11, 'db1295af-35f6-485b-a0b2-a2c609b16029': 92, 'd9f824f0-c2d3-4fdb-a8d0-604a80856601': 63, 'd54aeec0-a8d8-4376-8afb-984f333bcd43': 58, 'd231a45b-f8a4-46f0-9bd9-d2a33c006e8a': 24, 'cd0736ee-469e-4059-83b0-3b0462c5600f': 95, 'cb1c8bf3-711a-441f-b73c-4543702a866b': 92, 'c7f07d64-f9e0-488a-b3e1-54dc9b09fb72': 52, 'c7b708ed-d790-4c34-9e3c-850fb81d6924': 24, 'c4692b54-cd7c-46e3-9b91-6ba933fd737b': 58, 'bfe03e58-31ca-4ad6-87b6-b6ea98fff91e': 92, 'bf1fbf05-d064-4b05-b13e-a0880b4979bc': 58, 'bec1725f-1c01-4d1e-9ddb-625965308e7f': 58, 'bbdf046f-2a3b-431f-9f61-3f78707a7d0f': 24, 'b90a34d1-78b3-489f-9261-e8d79f09db35': 25, 'b887f93d-5984-44c0-9817-e04cacfed8ab': 92, 'b7f1aac7-aa3e-4764-b3e2-5262973ea60b': 92, 'b5a85629-3338-4619-83b1-e268597a49af': 92, 'b328848e-18d1-4fbd-8f7f-4a463e1b3cbb': 63, 'b1ac86f2-9fc1-40b1-ada3-58f98d050e7e': 58, 'b16c5c44-99f7-436a-925f-491b5d015037': 92, 'b021c28c-898d-4c6b-978c-3cb838173b6f': 95, 'a0bf2932-7c2b-4ee6-a26a-a52daec242f2': 83, 'a05d8f64-c12b-4f5a-9ddf-5ab983cbf589': 95, 'a025eb4c-42d4-4122-8506-a3dc9ee04f6c': 83, '9d4476b9-6f08-4ac2-aaec-a5905da91f59': 36, '9c23d210-8b9a-4dad-ad45-724265c5ecd0': 95, '9a1602eb-3ab4-44d3-b106-54aa9093e789': 83, '991549db-c7a7-4b6d-a2ae-abc7a6480f8a': 92, '97e4def0-2f4c-46a8-900e-638ab1141696': 92, '97dfd97f-224d-469e-8e78-faaa0876f148': 92, '936cdc4f-1f52-4fe0-89f5-86381fefd895': 95, '9344a279-12a4-4d02-811a-61153d7ba0c5': 58, '8c337caf-808e-4865-bd04-6eedd79b103f': 94, '8bf223bf-6dfd-40ec-a824-67f6a5799bfd': 92, '89777fbf-18ff-4920-aa1b-c6d0ab76c444': 54, '8518597e-e051-4233-b146-3f4e8033a9f0': 58, '8141143f-e465-4e92-8bb8-8fd3bc2942d9': 94, '8095aabc-fa02-4156-b9ec-7b18973ff4fb': 63}}

StephenBadger avatar Apr 26 '25 19:04 StephenBadger

This would be the fix I am using locally:

diff --git a/graphiti_core/utils/maintenance/community_operations.py b/graphiti_core/utils/maintenance/community_operations.py
index 15bab42..61e399a 100644
--- a/graphiti_core/utils/maintenance/community_operations.py
+++ b/graphiti_core/utils/maintenance/community_operations.py
@@ -82,8 +82,10 @@ def label_propagation(projection: dict[str, list[Neighbor]]) -> list[list[str]]:
     # 2. Each node will take on the community of the plurality of its neighbors
     # 3. Ties are broken by going to the largest community
     # 4. Continue until no communities change during propagation
-
+    MAX_ITERATIONS = 30  # Prevent infinite loops
     community_map = {uuid: i for i, uuid in enumerate(projection.keys())}
+    iteration = 0

     while True:
         no_change = True
@@ -112,7 +114,8 @@ def label_propagation(projection: dict[str, list[Neighbor]]) -> list[list[str]]:
             if new_community != curr_community:
                 no_change = False

-        if no_change:
+        iteration += 1
+        if no_change or iteration >= MAX_ITERATIONS:
             break

         community_map = new_community_map

StephenBadger avatar Apr 26 '25 19:04 StephenBadger

I believe I'm running into the same issue. MCP gets stuck after building communities

bloomt avatar Apr 26 '25 21:04 bloomt

I tried your patch but I still timeout during "Building communities" and any commands after fail

bloomt avatar Apr 28 '25 15:04 bloomt

How did you apply it? Are you using the docker? If you are using the docker you need to adjust the dockerfile so that you build with the patch. I've been having no issues since making the changes.

I copy graphiti core into the mcp_server folder, then i adjust the dockerfile to look like this

FROM python:3.11-slim

WORKDIR /app

# Install uv
RUN apt-get update && apt-get install -y curl && \
    curl -LsSf https://astral.sh/uv/install.sh | sh && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

ENV PATH="/root/.local/bin:${PATH}"

# Install dependencies first (graphiti will also be installed, but we'll overwrite it)
COPY pyproject.toml .
RUN uv sync

# Copy application code
COPY graphiti_mcp_server.py .
# COPY core into the image, so its used rather then their external lib
COPY graphiti_core/ graphiti_core/

EXPOSE 8000

ENV PYTHONUNBUFFERED=1

# Make sure our local code gets used first
ENV PYTHONPATH="/app:${PYTHONPATH}"

CMD ["uv", "run", "graphiti_mcp_server.py"]%    

Then i rebuild the image without a cache. Then i have no issues

StephenBadger avatar Apr 28 '25 19:04 StephenBadger

Is this issue still unresolved? @prasmussen15 @galshubeli (Since this appears to be a clear bug, and I’m not sure who to contact directly, I’m mentioning you here based on your involvement in the pull request.)

From my testing, the infinite loop problem can be fixed with the code changes above, but I’m still encountering a type mismatch error for the community.name_embedding field.

I've just tested with quickstart_falkordb.py, building community by await graphiti.build_communities([group_id]) (There was an error in this code because group_id was not provided, so I assigned one manually.), and used COMBINED_HYBRID_SEARCH_RRF instead of NODE_HYBRID_SEARCH_RRF.

It seems that Vectorf32 is expected, but a List type is being stored instead:

2025-08-11 10:46:38 - graphiti_core.driver.falkordb_driver - ERROR - Error executing FalkorDB query: Type mismatch: expected Null or Vectorf32 but was List
Query example:

MATCH (n:Community)
WITH n,
     (2 - vec.cosineDistance(n.name_embedding, vecf32($search_vector)))/2 AS score
WHERE score > $min_score
RETURN
    n.uuid AS uuid,
    n.name AS name,
    n.name_embedding AS name_embedding,
    n.group_id AS group_id,
    n.summary AS summary,
    n.created_at AS created_at
ORDER BY score DESC
LIMIT $limit

jaehyoyoo708 avatar Aug 11 '25 02:08 jaehyoyoo708

Is this issue still unresolved? @prasmussen15 @galshubeli (Since this appears to be a clear bug, and I’m not sure who to contact directly, I’m mentioning you here based on your involvement in the pull request.)

From my testing, the infinite loop problem can be fixed with the code changes above, but I’m still encountering a type mismatch error for the community.name_embedding field.

I've just tested with quickstart_falkordb.py, building community by await graphiti.build_communities([group_id]) (There was an error in this code because group_id was not provided, so I assigned one manually.), and used COMBINED_HYBRID_SEARCH_RRF instead of NODE_HYBRID_SEARCH_RRF.

It seems that Vectorf32 is expected, but a List type is being stored instead:

2025-08-11 10:46:38 - graphiti_core.driver.falkordb_driver - ERROR - Error executing FalkorDB query: Type mismatch: expected Null or Vectorf32 but was List
Query example:

MATCH (n:Community)
WITH n,
     (2 - vec.cosineDistance(n.name_embedding, vecf32($search_vector)))/2 AS score
WHERE score > $min_score
RETURN
    n.uuid AS uuid,
    n.name AS name,
    n.name_embedding AS name_embedding,
    n.group_id AS group_id,
    n.summary AS summary,
    n.created_at AS created_at
ORDER BY score DESC
LIMIT $limit

Hi @jaehyoyoo708, we fixed the vectorization in https://github.com/getzep/graphiti/pull/824 and the empty group_id error in https://github.com/getzep/graphiti/pull/775. Thank you for bringing this up, and we hope it will be released asap.

galshubeli avatar Aug 11 '25 05:08 galshubeli

I appreciate your prompt response. :)

jaehyoyoo708 avatar Aug 11 '25 05:08 jaehyoyoo708

+1

theobjectivedad avatar Oct 01 '25 16:10 theobjectivedad

@StephenBadger Is this still an issue? Please confirm within 14 days or this issue will be closed.

claude[bot] avatar Oct 17 '25 00:10 claude[bot]

it is not resolved yet. the while loop in community_operations.py can still be infinite

kftam1994 avatar Oct 17 '25 00:10 kftam1994

@StephenBadger Is this still an issue? Please confirm within 14 days or this issue will be closed.

claude[bot] avatar Oct 22 '25 00:10 claude[bot]

@StephenBadger Is this still an issue? Please confirm within 14 days or this issue will be closed.

claude[bot] avatar Oct 29 '25 00:10 claude[bot]

+1 on the infinite loop issue using the core library. The local fix will work but I have had code hang for hours in label_propagation.py with no indication that anything was amiss.

awinde avatar Nov 03 '25 22:11 awinde