graphify icon indicating copy to clipboard operation
graphify copied to clipboard

`query` prints the TRUNCATED banner when 0 nodes were cut

Open austxio opened this issue 3 months ago • 2 comments

Problem

The truncation banner prints even when nothing was truncated. Two real outputs from a production repo (graphify 0.9.25, 8,437-node graph):

[!] TRUNCATED: showing 91 of 91 nodes (~6000-token budget). The answer may be
among the 0 cut nodes

and, reproduced today at the tail of a query --context call --budget 6000 result:

... (truncated — 0 more nodes cut by ~6000-token budget. Narrow with context_filter=['call'] or use get_node for a specific symbol)

The message construction in graphify/serve.py at current HEAD interpolates cut_count into the banner without a zero guard, so the wording survives to today's source.

Why it matters more than cosmetics

The banner's audience is usually an agent, and agents act on it:

  • "The answer may be among the 0 cut nodes" teaches the reader to distrust a complete answer.
  • An agent following the banner's own advice issues follow-up narrowing calls (context_filter, get_node) to recover nodes that were never cut — pure wasted round-trips.

Suggested fix

Suppress the banner when cut_count == 0 (and when shown == total for the [!] TRUNCATED: showing N of N variant). If the budget was reached but no whole node was dropped, that is a complete answer and should render as one.

austxio avatar Aug 10 '26 23:08 austxio

Hi, id like to work on this if possible can i have it assigned to me?

yeti107 avatar Aug 11 '26 15:08 yeti107

Fixed in v0.9.41 (graphifyy==0.9.41 on PyPI). query only prints the truncation banner when nodes were actually cut; when only trailing edges overflowed the budget the banner is suppressed (and a genuine node truncation still warns). Thanks @ousamabenyounes (PR #2662).

safishamsi avatar Aug 12 '26 13:08 safishamsi