Skip to content

explore: encourage the graph for code — typed graph-search and graph-get — without forcing it - #1760

Merged
Evanfeenstra merged 2 commits into
mainfrom
feature/explore-graph-first
Oct 10, 2026
Merged

Evanfeenstra merged 2 commits into
mainfrom
feature/explore-graph-first

Conversation

@Evanfeenstra

@Evanfeenstra Evanfeenstra commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Even with #1758's repository note, the explorer answered every code question by grep, and nothing in the prompt said what the graph is good for. But the graph is parsed from the code, so it isn't a perfect syntax tree. Grep and the files stay first-class; this encourages the graph without forcing it.

What

  • System prompt: the graph and the files are two ways into the code; use whichever fits.
    • The graph is strong for finding something by what it does and for walking calls.
      1. graph/graph-search with type set to code node types, Function,Class,Datamodel,Endpoint,Request,Page,File, narrowed per question;
      2. graph-get the hits that look right. A search result has no file path; the node has file, start/end, body/interface and a description, often enough to answer and cite <repo>/<path>:<lines>;
      3. graph-neighbors / walk.
    • The files whenever they serve better: an exact string, path or config value; a repository the graph didn't parse; lines a node doesn't carry; a node that looks wrong or incomplete. When the graph and a file disagree, the file is right.
    • Citations: cite the node for code read as a node, the file for code read in a file.
  • explore/repositories note: the same type list and graph-get advice, plus "use fulltext_search and the file tool whenever they serve better".

Observed (swarm38, same question each time, run with the prompt as a params.system override)

The question named an exact route path.

run prompt tools
1791664501161 #1758 grep, 2 file views
1791664949002 an earlier draft with a hard "graph_get before any file" rule graph_search → graph_get → graph_search → graph_get → graph_neighbors, no files
1791665463791 this PR grep, 2 file views ($0.08)

On this exact-path question the agent still picks grep, which is the case the prompt now says files are for. Graph use on questions by behavior ("what calls X", "where is Y handled") wasn't sampled. Files read directly are going to show in hive's Graph Trace as their File nodes (next PR, hive), so a grep-first exploration still shows what it read.

Tests

explore/seed.test.ts checks the type list, the graph-get advice, "go to the files whenever they serve better", "the file is right", and that the prompt has no "Never grep". tsc is clean.

…-get before any file

The repository note alone did not move the explorer off grep (swarm38 explore
1791664501161: 1 fulltext_search + 2 views, 0 graph calls, the note in its
prompt). Typed search came next, then the agent grepped for the path a hit
named: a search result carries no file. The system prompt now orders it —
graph-search with type Function,Class,Datamodel,Endpoint,Request,Page,File
(narrowed per question), graph-get the hits (a code node has its file, start/
end, body, description), never grep for or open a file a hit names before its
node is read — and a source for code in an ingested repository is the node.
Same question with this prompt as a params override (1791664949002): search →
get → search → get → neighbors, no files, high confidence, file:lines cited
from the nodes, $0.10 as before.
…rve better

The graph is parsed from the code and can miss or misplace things; grep and
the files stay first-class. Drop the hard rule (never grep for or open a file
before reading its node); keep the typed search over the code node types and
why graph-get pays (a node carries its file, lines, body, description); say
when the files serve better (an exact string, path or config value; lines a
node lacks; a node that looks wrong) and that the file wins a disagreement.
Cite the node when the code was read as one, the file otherwise.
@Evanfeenstra Evanfeenstra changed the title explore: graph first — typed graph-search over code node types, graph-get before any file explore: encourage the graph for code — typed graph-search and graph-get — without forcing it Oct 10, 2026
@Evanfeenstra
Evanfeenstra merged commit 995b844 into main Oct 10, 2026
3 checks passed
Evanfeenstra added a commit that referenced this pull request Oct 12, 2026
* explore: begin with one graph search when the graph holds the code

The softened prompt (#1760) still left the graph unused on a broad question
about what the code does — the case it said the graph is for (swarm38 explore
run 1791735843683: grep, file_summary and views only). One typed graph search
comes first now; after it, whichever fits.

* explore: a search hit carries its file and lines, and the graph counts lines from 0

strut#142 adds `file`, `start` and `end` to graph/graph-search's hits, so the
prompt's "a search result has no file path; the node has it" stops being
true. And stakgraph's lines are 0-based (swarm38: computeHmacSha256Hex is
start 152, end 154 for lines 153-155), so citing <repo>/<path>:<start>-<end>
pointed one line early: the prompt now says a node covers start+1 to end+1
and cites that.
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