extract: a timed-out chunk re-pays the full timeout on every split, so one chunk can burn ~2.5h (claude-cli)
Bug
With --backend claude-cli, a semantic chunk that exceeds the API timeout is split in half and retried recursively. Each retry re-pays the full timeout, so one chunk that cannot finish in the default 600 s can consume up to ~2.5 hours before the cascade gives up.
Observed on a 20-chunk run: chunks 1–2 completed, then no progress for ~2 hours on chunk 3.
[graphify extract] semantic extraction on 220 files via claude-cli...
[graphify extract] chunk 1/20 done
[graphify extract] chunk 2/20 done
[graphify] chunk of 17 timed out at depth 0 (TimeoutExpired); splitting in half and retrying
[graphify] chunk of 9 timed out at depth 1 (TimeoutExpired); splitting in half and retrying
[graphify] chunk of 4 timed out at depth 2 (TimeoutExpired); splitting in half and retrying
It reads as a hang. The giveaway that it was blocked rather than working: the process had 61 seconds of CPU across 2 hours of wall clock.
Arithmetic
_resolve_api_timeout(default: float = 600.0)— 600 s per call (llm.py:404)- On
TimeoutExpired, the chunk splits and each half retries recursively tomax_depth=3(llm.py:~2391), i.e. up to2**3 = 8leaf pieces - Every attempt gets a fresh 600 s
Worst case for a single original chunk:
600 x (1 + 2 + 4 + 8) = 9,000 s = 2.5 hours
The recursion is correctly bounded — this is not an infinite loop. The problem is that the timeout is treated as a per-attempt allowance rather than a budget for the whole subtree, so bounding the depth does not bound the cost.
Why claude-cli hits this routinely
Every semantic call spawns a whole nested claude -p agent session, which is far slower than an HTTP completion. A 600 s default that is comfortable for an API backend is easily exceeded here on a large chunk, so the cascade triggers in normal use rather than as an edge case.
Workaround
GRAPHIFY_API_TIMEOUT=1800 fixed it outright — the identical run then completed all 20 chunks and wrote the graph.
For anyone else hitting this: note that GRAPHIFY_CLAUDE_CLI_PARALLEL does not help. llm.py:2614 already pins claude-cli to max_concurrency = 1 unless that variable is exactly "1", so setting it to any other value is a no-op. (I initially believed lowering concurrency was the fix; it was not.)
Suggestions
- Scale the default timeout by backend.
claude-clispawns an agent session per call; 600 s is a reasonable HTTP default but too low here. - Make the timeout a subtree budget. Track elapsed time across the split cascade and abandon once the original allowance is spent, instead of granting each of up to 15 attempts a fresh full timeout.
- Announce the cascade. When a split starts, log the worst-case cost it has just committed to. Right now the only signal between "chunk 2/20 done" and completion is silence, which is indistinguishable from a hang.
Environment
- graphify 0.9.50 (pipx), Python 3.14, Windows 11
graphify extract . --backend claude-cli- Corpus: ~2,200 markdown notes plus scripts; 315 files re-extracted, 975 cached