Skip to content

Rationale instruction missing from _EXTRACTION_SYSTEM: API backends silently drop what subagents capture #2482

Closed

Description

@maxx1980

Summary

_EXTRACTION_SYSTEM — the prompt used by every API backend (deepseek, gemini, openai, kimi, …) — never asks the model to record design rationale. The Claude-subagent prompt distributed with the graphify skill does. The result is that the same corpus yields rationale-rich nodes when extracted via subagents and rationale-free nodes when extracted via an API key, with no warning that anything was dropped.

Detail

In graphify/llm.py on master, _EXTRACTION_SYSTEM starts at L450. The string rationale occurs in it exactly once, at L478 — as an allowed file_type value inside the output schema:

"file_type":"code|document|paper|image|rationale|concept"

There is no instruction telling the model what rationale is or where to put it, and the node object printed in that schema has no rationale key at all. So a model is told rationale is a legal node type while the concept is never explained, and the attribute form is never mentioned.

The subagent prompt shipped with the skill (references/extraction-spec.md) is explicit about the opposite convention:

For rationale (WHY decisions were made, trade-offs, design intent): store as a rationale attribute on the relevant concept node — do NOT create a separate rationale node or fragment node.

So the two extraction paths disagree both on whether rationale is collected and on how it is represented.

Reproduction

Corpus: three README files (~40k words of fairly rationale-dense documentation) from a Go + Svelte project.

extraction path nodes edges nodes carrying rationale
Claude subagents (skill prompt) 46 109 35
extract_corpus_parallel(backend="deepseek"), graphify 0.9.5 68 109 0

Same files, same repo, same run of the pipeline otherwise.

Monkey-patching the instruction back in confirms the prompt is the cause rather than model capability:

from graphify import llm
llm._EXTRACTION_SYSTEM += RATIONALE_INSTRUCTION   # ~15 lines, same wording as the skill prompt
llm.extract_corpus_parallel(files, backend="deepseek", root=root)

→ 46 nodes, 21 carrying a rationale. Model: deepseek-v4-flash.

Two things worth noting for whoever fixes this

  1. It is not free. In that patched run, edges dropped from 109 to 65 for the same files. Adding a per-node obligation appears to crowd out relationship extraction under a fixed output budget, so the instruction probably wants pairing with something like "extract the full relationship set first, then attach rationale".
  2. Models will fill the field with descriptions. Roughly half of the 21 rationales were restatements of what the thing does rather than why it is that way (e.g. a key-management node whose rationale read "Generates keypairs (ed25519/rsa/ecdsa) and deploys public keys…"). An explicit "if the source states no reason, omit the field — do not restate the description" helps.

Suggested fix

Move the rationale instruction into _EXTRACTION_SYSTEM so both paths share it, and add the optional rationale key to the node object in the printed schema. That also makes the existing rationale file_type value coherent — right now it is the only hint the feature exists.

Environment

  • graphify 0.9.5 (installed via pipx, Python 3.12); behaviour verified unchanged on master as of this report — rationale still appears exactly once in _EXTRACTION_SYSTEM
  • backend: deepseek / deepseek-v4-flash
  • Linux, zsh

Activity

  1. safishamsi commented on Aug 12, 2026

    @safishamsi
    Member

    Fixed in v0.9.41 (graphifyy==0.9.41 on PyPI). The API extraction prompt now instructs backends to capture the per-node rationale attribute, matching the skill path, so API-backed extraction no longer silently drops it. Thanks @hopstreax (PR #2515).

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