Skip to content

Bug: /graphify skill ignores detect_backend() — only uses Gemini, ignores OPENAI_API_KEY/ANTHROPIC_API_KEY/etc. the CLI supports #2513

Open

Description

@proletariat64

Summary

The /graphify skill (all platform variants: skill.md, skill-pi.md, skill-codex.md, …) hardcodes a Gemini-only API-key check for semantic extraction and explicitly claims Graphify reads no other provider keys. This is contradicted by graphify/llm.py, which ships a full multi-provider detect_backend() with priority gemini→kimi→claude→openai→deepseek→azure→bedrock→ollama→custom. As a result, users who only have OPENAI_API_KEY (+ OPENAI_BASE_URL for any OpenAI-compatible server: llama.cpp / vLLM / LM Studio / a local proxy), or ANTHROPIC_API_KEY, MOONSHOT_API_KEY, DEEPSEEK_API_KEY, etc. set in their environment cannot use those backends through the skill — they silently fall back to the slower host-agent subagent path even though the CLI would happily extract via that backend.

Environment

  • graphifyy 0.9.33 (also reproduced against the latest 0.9.34 metadata; skill text identical)
  • Installed via uv tool
  • Verified by reading the installed graphify/llm.py and graphify/skill*.md

The problem

In every shipped skill, Step 3 ("Extract entities and relationships") says:

Semantic extraction (only for docs, papers, and images) uses Gemini only if GEMINI_API_KEY/GOOGLE_API_KEY is already set; otherwise the host agent itself is the LLM. graphify does not read ANTHROPIC_API_KEY, OPENAI_API_KEY, or any other provider key.

and

No other API keys are read.

These two statements are factually false. graphify/llm.py defines a BACKENDS table and a detect_backend() function that read and prioritize exactly those keys:

  • llm.py detect_backend() — priority gemini → kimi → claude → openai → deepseek → azure → bedrock → ollama → custom (the docstring even notes Ollama is deliberately checked last so a paid key is never shadowed)
  • llm.py openai backend config: base_url = os.environ.get("OPENAI_BASE_URL", ...), default_model = os.environ.get("OPENAI_MODEL", "gpt-4.1-mini"), env_key = "OPENAI_API_KEY", model_env_key = "GRAPHIFY_OPENAI_MODEL" — i.e. any OpenAI-compatible server is a first-class backend
  • llm.py also has claude (ANTHROPIC_API_KEY/ANTHROPIC_BASE_URL), kimi (MOONSHOT_API_KEY), deepseek (DEEPSEEK_API_KEY), azure, bedrock, ollama, plus custom providers from ~/.graphify/providers.json
  • extract_corpus_parallel(files, backend=...) accepts any of them

The Gemini-only branch in the skill never calls detect_backend() and hardcodes backend="gemini", so the entire provider layer the CLI exposes is invisible to the skill.

Root source of the text is the shared skillgen fragment tools/skillgen/fragments/core/core.md; all 17 platform skill variants (graphify/skill*.md) are generated from it, so the fix should land in the fragment and be regenerated.

Impact

  • Users with only OPENAI_API_KEY + OPENAI_BASE_URL (very common for self-hosted / local OpenAI-compatible servers) cannot extract docs/papers/images through the skill; they fall back to host-agent subagents — slower and billed against the agent's own model instead of the configured extraction backend.
  • Same for ANTHROPIC_API_KEY, MOONSHOT_API_KEY, DEEPSEEK_API_KEY.
  • The --backend openai path of graphify extract works perfectly, so the gap is purely in the skill's orchestration — confusing for users who see the CLI work but the skill not use it.
  • The "graphify does not read OPENAI_API_KEY" / "No other API keys are read" statements are misleading documentation.

Suggested fix

In the skill (root fix in tools/skillgen/fragments/core/core.md), replace the Gemini-only check with the CLI's own provider detection:

from graphify.llm import detect_backend, extract_corpus_parallel
backend = detect_backend()
if backend:
    # use the detected backend (gemini/kimi/claude/openai/deepseek/azure/bedrock/ollama/custom)
    result = extract_corpus_parallel(files, backend=backend, root=root)
    # write graphify-out/.graphify_semantic.json, skip Part B subagent dispatch
else:
    # no key/endpoint configured at all → host-agent subagent fallback (unchanged)
  • Model auto-resolves via GRAPHIFY_<NAME>_MODEL / <NAME>_MODEL env vars or the backend default (already implemented by _default_model_for_backend).
  • Keep the existing host-agent fallback for the detect_backend() is None case — that part of the design is good.
  • Correct the two false "does not read other keys" / "No other API keys are read" sentences.

Local verification

I patched my installed SKILL.md to call detect_backend() and tested on a small corpus (docs.md + app.py) with OPENAI_API_KEY + OPENAI_BASE_URL=http://localhost:20128/v1 + GRAPHIFY_OPENAI_MODEL=cx/gpt-5.3-codex-spark set (no Gemini key):

graphify_backend=openai
graphify_model=cx/gpt-5.3-codex-spark
routing semantic extraction through backend=openai (skill subagent path SKIPPED)
semantic nodes=7 edges=4 input_tokens=808 output_tokens=2976
SKILL_OPENAI_ROUTING_TEST=PASS
merged nodes=10 edges=7 (AST=3 + semantic=7)

The skill routed docs through the local OpenAI-compatible endpoint directly and skipped subagent dispatch, while code still went through the AST path. CLI graphify extract . already auto-selects openai in the same env, confirming the layer the skill needs to call is already there.

Happy to open a PR against tools/skillgen/fragments/core/core.md (+ regenerate the skill variants) if that's wanted.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions