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
Community labeling returns empty content with reasoning models (reasoning consumes the completion budget; split-retry reduces the budget further) #3747
Community labeling (graphify label) returns empty completions and falls back to Community N placeholders when the backend is an OpenAI-compatible reasoning model (custom provider via graphify provider add). Every batch fails, including after the adaptive split-retries:
[graphify label] batch of 2 still unparseable at depth 3 (cids=[0, 1]): label response is not parseable JSON: ''
[graphify label] batch 1/1 (20 communities) failed: label response is not parseable JSON: ''
[graphify label] warning: community labeling failed (...); using Community N placeholders.
Model: deepseek/deepseek-v4.1-flash (a reasoning model: long chain-of-thought returned separately from content)
Corpus: small Next.js repo, 20 communities
Root cause (traced)
Instrumenting graphify.llm._call_llm shows the retries make decreasing budgets: 1216 -> 736 -> 496 -> 352 tokens, all returning an empty string. Replaying the exact saved prompts through the OpenAI SDK against the same endpoint/model:
max_tokens
finish_reason
content
reasoning chars
completion_tokens
1216
length
'' (empty)
~4,300
1216
8192
stop
full JSON
~11,300
3112
1216, fast non-reasoning model
stop
full JSON
-
-
So the model spends its entire completion budget on the reasoning chain and returns finish_reason=length with empty content. _parse_label_response correctly cannot salvage an empty string, but the adaptive retry (#1278) splits the batch, which only shrinksmin(256 + 48 * n, 8192) - the retry moves in the wrong direction for a budget-exhaustion failure, so it can never recover.
Suggested fix
Treat empty content / finish_reason == "length" distinctly in _label_batch_with_retry: first retry with a larger max_tokens (e.g. x2, capped at 8192), and only split the batch if the larger budget still fails.
Consider disabling thinking for the labeling call via extra_body (like the moonshot default {"thinking": {"type": "disabled"}}) or passing reasoning_effort: "low".
Optionally expose an env/CLI override for the labeling budget.
Workaround
Using a fast/non-reasoning model labels all communities successfully at the same budget: graphify label . --backend myendpoint --model deepseek/deepseek-v4-flash-fast
Activity