Skip to content

fix(tool): report a separator-only fetch selection as not found - #791

Merged
Ishaan Gangwani (ishaan1124) merged 2 commits into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/webfetch-empty-selector
Sep 29, 2026
Merged

Ishaan Gangwani (ishaan1124) merged 2 commits into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/webfetch-empty-selector

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

What

pick() returns the entire parsed document when the selector names no step, and shapeJson() then reports the selection as successful.

const steps = selector.match(/[^.[\]]+|\[-?\d+\]/g) ?? []
// "." , ".." , "["  ->  the class matches nothing  ->  steps === []
for (const step of steps) { ... }   // never runs
return current                     // current is still the whole document

Why it matters

The model asks to keep one narrow path, gets told selected 1 path from N characters, and receives the full 40,000-character body plus (Selection truncated at 40,000 characters; select narrower paths.).

The not found: clause in the note is the one signal that would have told it to retry — and because nothing is undefined, that clause is exactly what gets suppressed. So a malformed selector costs a wasted turn and 40 KB of context, while the tool reports success.

Verification

Fails before, passes after:

error: expect(received).toBeUndefined()
Received: { ...the whole pypi document... }
(fail) a selector of only separators names no path
(pass) pick reads dotted keys, indexes and the last element
(pass) a selector of only separators names no path
(pass) a selection keeps only the asked paths and names the ones not found
(pass) an unselected registry document past the inline cap is cut ...
 4 pass
 0 fail

The new test asserts all three degenerate forms (., .., [) and checks the shaped note reports not found: ., so the fix is pinned at both layers — the helper and the note the model actually reads.

The change

   const steps = selector.match(/[^.[\]]+|\[-?\d+\]/g) ?? []
+  // A selector made only of separators (".", "..", "[") tokenizes to nothing, so
+  // the walk below would have no step to take and return the whole document.
+  // That reads to the caller as a narrow selection that succeeded, and it is
+  // the one note that would have told the model to retry with a real path.
+  if (!steps.length) return undefined
   let current: unknown = value

No behaviour change for any selector that names at least one step.

bun run typecheck clean; touched files are Prettier-clean (checked on LF-normalized copies — this checkout has core.autocrlf=true, which makes Prettier flag every file in the repo).

Fixes #790

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

The selector tokenizer matches neither keys nor indexes for a selector like . or .., so pick() had no step to walk and returned the whole document. shapeJson then saw no undefined and reported the selection as successful, suppressing the note that tells the model to retry with a real path.
@ishaan1124
Ishaan Gangwani (ishaan1124) merged commit 05a4cec into synthetic-sciences:main Sep 29, 2026
8 of 9 checks passed
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.

A web fetch selection of only dots returns the whole document and still reports success

2 participants