You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
label_communities ignores _resolve_max_tokens() — hardcoded token budget truncates label responses for graphs with 50+ communities #1200
label_communities (llm.py:1855) uses a hardcoded max_tokens formula that ignores the existing _resolve_max_tokens() helper (llm.py:232), making GRAPHIFY_MAX_OUTPUT_TOKENS a dead env var for the labeling path. On graphs with many communities, the formula undershoots and the LLM response is truncated, producing unparseable JSON.
How we hit it
graphify extract . --backend deepseek on a Rust project (~215 files) → 1650 nodes, 3596 edges
Clustering produced 92 communities
graphify label . --backend deepseek failed with:
[graphify label] warning: community labeling failed (Unterminated string starting at: line 7 column 8 (char 186)); using Community N placeholders.
Root cause
label_communities at line 1855 calculates its own token budget:
The prompt instructs the model to output a JSON object mapping 92 community IDs to 2-5 word labels. At ~15-20 tokens per entry (JSON key + quoted string + comma), the response needs roughly 1,400-1,800 tokens. At 1512, the model runs out of tokens mid-response, truncating the JSON string and producing an unparseable payload.
Meanwhile, _resolve_max_tokens() exists at line 232 specifically to let users override token budgets via GRAPHIFY_MAX_OUTPUT_TOKENS, and the main extraction path uses it (lines 1121, 1152). But label_communities never calls it — the env var is silently ignored for labeling.
Workaround
Patched line 1855 locally to increase the per-community token allocation:
This gives the model enough headroom (4096 tokens for 92 communities) to complete the full JSON response without truncation. After applying this patch, graphify label . --backend deepseek succeeded and produced names for all 92 communities.
Fixed in e477825. Replaced the hardcoded min(40 + 16 * n, 4096) formula in the label_communities batch loop with _resolve_max_tokens(min(64 + 24 * n, 8192)). New budget: 2,464 tokens for 100 communities (was 1,640). GRAPHIFY_MAX_OUTPUT_TOKENS env var now honoured for the labeling path.
Activity
fix: three correctness bugs — cycle hang, label token budget, fuzzy d…
safishamsi commentedon Jun 8, 2026
Fixed in e477825. Replaced the hardcoded
min(40 + 16 * n, 4096)formula in thelabel_communitiesbatch loop with_resolve_max_tokens(min(64 + 24 * n, 8192)). New budget: 2,464 tokens for 100 communities (was 1,640).GRAPHIFY_MAX_OUTPUT_TOKENSenv var now honoured for the labeling path.fix: three correctness bugs — cycle hang, label token budget, fuzzy d…