Repository navigation
extract: --fallback-backend retries a zero-success semantic pass on a second backend - #2
Conversation
… on a second backend When every semantic chunk fails on the primary backend (missing SDK package, bad key, an outage), a configured fallback backend retries the same still-uncached files once instead of failing the build. Nothing is cache-saved for a zero-success pass, so the retry covers exactly the files the primary failed on. --model belongs to the primary backend and is not forwarded, the fallback name is validated before any API spend, and only a zero-success retry keeps the all-chunks-failed exit 1. GRAPHIFY_FALLBACK_BACKEND sets the default; the CLI flag wins. Co-Authored-By: Claude Fable 5 <[email protected]>
Review addition: the no-double-spend edge — when the primary backend got at least one semantic chunk through, --fallback-backend must NOT re-dispatch the whole uncached set on the second backend. Locks the succeeded == 0 trigger condition in place. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6269f9139a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fresh, _chunk_stats = _dispatch_semantic( | ||
| fallback_backend, uncached_paths | ||
| ) |
There was a problem hiding this comment.
Validate Ollama's URL before fallback dispatch
When the primary pass fails and ollama is selected as the fallback, this dispatch bypasses the CLI's primary-backend _validate_ollama_base_url gate. If OLLAMA_API_KEY is set, extract_files_direct also skips its own validation, so an OLLAMA_BASE_URL pointing at a link-local or cloud-metadata address receives a request containing corpus data despite the project's intended hard block. Apply the same Ollama URL validation before invoking the fallback.
Useful? React with 👍 / 👎.
| ) | ||
| fresh = {"nodes": [], "edges": [], "hyperedges": [], "input_tokens": 0, "output_tokens": 0} | ||
| _extraction_incomplete = True # the semantic pass crashed | ||
| _last_backend = fallback_backend |
There was a problem hiding this comment.
Price fallback tokens with the backend that handled them
After a successful fallback, fresh and its token totals come from fallback_backend, but both output paths later call _estimate_cost(backend, ...) and label the estimate with the primary backend. Whenever the providers have different pricing—for example, OpenAI falling back to Ollama or vice versa—the displayed cost can therefore be substantially wrong. Preserve the backend associated with the retained semantic result and use it for the estimate.
Useful? React with 👍 / 👎.
# Conflicts: # CHANGELOG.md # graphify/cli.py
What: new
graphify extract --fallback-backend <B>flag (orGRAPHIFY_FALLBACK_BACKENDenv var; the flag wins). When EVERY chunk of the semantic pass fails on the primary backend, the same still-uncached files are retried once on the fallback backend.Why: a missing SDK package, a bad API key, or a provider outage on the primary backend used to cost the whole build with exit 1. With a fallback configured, those exact failures are recovered automatically.
--modelstays with the primary (the fallback runs its own default model), a typo'd fallback name is rejected before any API spend, and a partially-succeeded primary pass never fires the fallback.Tests:
tests/test_fallback_backend.py(11 tests) — fallback fires only on zero success, exact file set retried, model not leaked to fallback, name validation, env-var/flag precedence, exit-1 kept when both fail. All offline, backends mocked.🤖 Generated with Claude Code