Skip to content

Native-backend extraction prompt never requests hyperedges (drifted from skill extraction-spec) #1430

Closed

Description

@safishamsi

Summary

graphify extract --backend <gemini|claude|claude-cli|openai|kimi|deepseek|bedrock|…> (the native, API/CLI semantic-extraction path) never produces hyperedges for any corpus. The agent/skill path produces them normally. The two extraction prompts had drifted apart.

Root cause

graphify has two semantic-extraction prompts:

  • Agent/skill path — tools/skillgen/fragments/references/shared/extraction-spec.md fully documents hyperedges: "if 3 or more nodes clearly participate together in a shared concept, flow, or pattern… add a hyperedge", with a populated schema example and a "max 3 per chunk" rule.
  • Native-backend path — graphify/llm.py:_EXTRACTION_SYSTEM only ever showed "hyperedges":[] (empty) in its output-schema example and never described what a hyperedge is. The prose Rules covered only nodes/edges; deep mode added only INFERRED edges.

So a model on the native path is literally shown an empty hyperedges array as the expected output and given zero guidance to populate it — it returns the empty array. The parse/merge side (llm.py merged["hyperedges"].extend(...)) and the consumers (report.py, export.py) already handle hyperedges, so it was purely a prompt gap, not plumbing.

git log -S hyperedge -- graphify/llm.py shows _EXTRACTION_SYSTEM never carried the instruction — long-standing drift, not a recent regression.

Impact

A documented, first-class flow (graphify extract --backend X) silently produced a lower-quality graph (no group/hyperedge relationships) than the agent-driven skill for the same corpus.

Reproduction (before the fix)

graphify extract <doc-corpus> --backend claude-cli --mode deep
# graph.json -> "hyperedges": []   (even for docs that clearly describe 3+ nodes participating together)

Fix

Fixed on v8 in aad3b47: brought llm._EXTRACTION_SYSTEM in line with the skill's extraction-spec.md — added the "3 or more nodes participate together" instruction and a populated schema example. Prompt-only change.

Verified end-to-end: a doc that previously produced 0 hyperedges now produces one, correctly relativized (per #1418):

hyperedges: 1
   source_file='architecture.md' | members=6 | Checkout Saga Distributed Transaction

Two guard tests (tests/test_llm_backends.py) now assert the native prompt requests hyperedges with a populated example, and that it shares the skill spec's hyperedge wording, so the two prompts can't silently diverge again.

Status

Fixed on v8, pending the next release. Filed for the record / searchability; safe to close once released.

Activity

  1. added
    bug
    on Jun 22, 2026
  2. added a commit that references this issue on Jun 22, 2026
  3. added a commit that references this issue on Aug 13, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions