[Bug]: graphify query prints a different answer on each run (BFS walks a set in hash order)

Aperta Adatta ai principianti
#5,109 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@rohit-jsfreaky ci sta già lavorando.

Dal 9/11/2026.

  • #5112 di @rohit-jsfreaky — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
search

Direzione di ricerca

Leggi _bfs in graphify/serve.py e segui come il suo ordine di visita influisce sull’output di graphify query e sul budget di token. Riproduci il problema con il ciclo PYTHONHASHSEED dell’issue, poi controlla la stessa query con seed diversi; il lavoro è completato quando l’output e gli archi mantenuti sono stabili tra le esecuzioni. Nell’issue non è indicato alcun file di test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Pre-flight checks
  • I have checked the Troubleshooting section in the README
What happened?

graphify query prints a different answer on every run, on the same graph. _bfs in graphify/serve.py walks each level as a set of node ids (frontier = set(start_nodes), for n in frontier:), so the EDGE lines come out in string-hash order, which Python randomizes per process. query is not in _HASHSEED_PINNED_COMMANDS, and the MCP server runs the same traversal in a long-running process, so nothing pins it. The order also decides which edges survive the token budget.

Distinct outputs over 10 runs (PYTHONHASHSEED 1 to 10):

repo query budget distinct outputs
flask how does url_for work 50k 10
click how does echo work 50k 10
django how does slugify work default 10
django how does the queryset build sql 50k 10

On a FastAPI template repo, graphify query 'how does cn() work' run 6 times gave 5 different outputs.

Steps to reproduce
cd flask && graphify update .
for s in 1 2 3; do PYTHONHASHSEED=$s graphify query "how does url_for work" --budget 50000 | md5sum; done

Three different hashes.

Error output or graph output

Example, first 3 contains EDGE lines on a tiny graph (one seed, 60 neighbours), seeds 1 / 2 / 3:

helper_7, helper_17, helper_6 | helper_1, helper_13, helper_17 | helper_18, helper_17, helper_8
Graphify version

0.9.105 (v8 at 5eedffa8)

Operating System

Windows (also seen on Linux)

Python Version

3.12

Installation Method

uv tool install (recommended)

Additional context

_dfs uses a list stack and is already stable. Related but different: #2817 and #1667 (cluster order), #3743 (hash seed pinned for other commands).

Lingua principale
Python
Stelle
124k
Fork
11.9k
Merge medio
2h 35m
PR unite (30g)
6

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Graphify-Labs/graphify

Tutte le issue di Graphify-Labs/graphify

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.