Skip to content

[Feature]: query: lead with the file that matches a natural-language question best, not the single best-scoring node #4480

Open

Description

@devkancheti4-design

Problem or use case

On a natural-language question, graphify query starts from the single best-scoring node, and the renderer prints the start nodes first. On a question of three or more words, that node is often a test, whose name repeats the words of the bug report, or a same-named helper in another file. The file the question is about usually matches through several of its nodes at once, each scoring a little lower, so it ends up behind them. An agent reading the answer starts in the wrong file.

Measured on SWE-bench Lite: 285 issues across 12 repos, graphs from graphify update, default BFS depth 2, 2,000-token budget, with the fix's changed files as the key.

  • Asked by the issue title, the fixed file is printed first for 78 of 285.
  • Of the 207 misses, the first file is a test 58 times, a file in the same folder 41 times, and a file elsewhere 108 times.
  • The fixed file is among the 50 best-scored nodes in 113 of those 207, so the ranking already holds it; it just doesn't lead.

Proposed solution

For a question of three or more terms:

  • sum the scores of the 50 best-scored candidates per file;
  • put the best node of the best file first among the start nodes, and keep the other seeds in their order behind it;
  • let a test file lead only when the question names tests, or when nothing else matches.

Short queries (identifier lookups) keep their exact match first. Explicit --seed values are untouched.

Fixed file printed first / in the first 3 / in the first 5 files, out of 285:

by title by title + 400 characters
v8 today 78 / 115 / 131 67 / 99 / 122
proposed 88 / 121 / 136 80 / 117 / 140

The constants were chosen on django and sympy. On the 10 other repos alone, right file first goes 24 → 27 by title and 20 → 29 by title + 400.

Alternatives considered

Area

Graph building or querying

Are you willing to submit a PR?

Yes, I can work on this

Activity

  1. github-actions commented on Oct 15, 2026

    @github-actions

    Thanks for opening this issue, @devkancheti4-design. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

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