Skip to content

extract: --fallback-backend retries a zero-success semantic pass on a second backend - #2

Merged
Azeem1985 merged 3 commits into
v8from
feat/fallback-backend
Aug 24, 2026
Merged

Azeem1985 merged 3 commits into
v8from
feat/fallback-backend

Conversation

@Azeem1985

Copy link
Copy Markdown

What: new graphify extract --fallback-backend <B> flag (or GRAPHIFY_FALLBACK_BACKEND env 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. --model stays 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

Azeem and others added 2 commits August 24, 2026 08:22
… 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]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread graphify/cli.py Outdated
Comment on lines 3664 to 3666
fresh, _chunk_stats = _dispatch_semantic(
fallback_backend, uncached_paths
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread graphify/cli.py Outdated
)
fresh = {"nodes": [], "edges": [], "hyperedges": [], "input_tokens": 0, "output_tokens": 0}
_extraction_incomplete = True # the semantic pass crashed
_last_backend = fallback_backend

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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
@Azeem1985
Azeem1985 merged commit dedb7ff into v8 Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant