fix: correctly flatten update_community results in add_episode#1421
Open
octo-patch wants to merge 1 commit intogetzep:mainfrom
Open
fix: correctly flatten update_community results in add_episode#1421octo-patch wants to merge 1 commit intogetzep:mainfrom
octo-patch wants to merge 1 commit intogetzep:mainfrom
Conversation
…etzep#1396) semaphore_gather returns a list of N tuples (one per coroutine), where each tuple is (list[CommunityNode], list[CommunityEdge]). The previous code unpacked this as `communities, community_edges = <list of N tuples>`, which only worked accidentally when exactly 2 nodes were extracted. Replace the tuple unpack with an explicit loop that extends the accumulated lists, making it work correctly for any number of extracted entity nodes.
SFEley
added a commit
to SFEley/graphiti
that referenced
this pull request
Apr 21, 2026
Cherry-picked from getzep#1421 (fixes getzep#1396). semaphore_gather returns a list of N tuples, not two parallel lists. Unpacking as `communities, community_edges = ...` only worked by accident when exactly 2 entity nodes were extracted. Replaces the unpack with an explicit accumulation loop that works for any N. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1396
Problem
add_episodecrashes withValueError: too many / not enough values to unpackwhen the number of extracted entity nodes is anything other than exactly 2.The root cause:
semaphore_gatherreturns a list of N tuples (one per coroutine), where each tuple is(list[CommunityNode], list[CommunityEdge]). The previous code did:This Python unpacking treats the returned list as if it has exactly 2 items, so it only worked by accident when
N == 2. ForN == 1it raisesValueError: not enough values to unpack; forN >= 3it raisesValueError: too many values to unpack.Solution
Replace the tuple unpack with an explicit accumulation loop:
This correctly aggregates results across all nodes regardless of how many entity nodes were extracted from the episode. Also adds explicit type annotations to
communitiesandcommunity_edgessince they were previously inferred aslist[Any].Testing
The fix is a straightforward logic correction with no behaviour change for callers — the returned
communitiesandcommunity_edgeslists now have the correct types and values for all N. No external dependencies are required to verify the logic.