bug(core): read_many_files skips explicitly requested binary assets in added workspace directories (regression from #30211)

Open Beginner friendly
#30,242 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
cli, testing

Research direction

Start with packages/core/src/tools/read-many-files.ts, especially ReadManyFilesToolInvocation.execute and isAssetExplicitlyRequested, then review the existing cases in packages/core/src/tools/read-many-files.test.ts. Add coverage for explicitly requested binary assets in a secondary workspace directory and by absolute path, while confirming generic wildcard patterns still skip assets. Done when the focused tests pass and the requested assets are read.

Written by the indexing model from the issue text.

Description

status/need-triage
What happened?

After #30211 (1930f2539), read_many_files skips explicitly requested non-text assets (images, PDFs, audio) whenever they live in a secondary workspace directory (added via --include-directories or /directory add), or when an absolute path is passed in include.

ReadManyFilesToolInvocation.execute (packages/core/src/tools/read-many-files.ts:246-281) globs include patterns against every directory in workspaceContext.getDirectories(). Then, at lines 344-360, it computes:

const relativePathForDisplay = path
  .relative(this.config.getTargetDir(), filePath)
  .replace(/\\/g, '/');

and passes relativePathForDisplay into isAssetExplicitlyRequested(include, relativePathForDisplay, filePath, matcherCache).

For a secondary workspace directory ws2 when targetDir is ws1, relativePathForDisplay is ../ws2/assets/logo.png:

  1. Path-qualified patterns like assets/logo.png or docs/*.pdf fail isMatchPath('../ws2/assets/logo.png'), and the basename fallback (!normalizedPattern.includes('/') at line 156) is skipped because the pattern contains /.
  2. Even passing the exact absolute path (/path/to/ws2/assets/logo.png) fails because isAssetExplicitlyRequested only matches against relativePath (never against normalizedFilePath), and normalizedPattern contains /.
Local Reproduction

Tested on main (e5d88fb2c / 0.70.0-nightly.20261110.g1603e9bab) with WorkspaceContext(ws1, [ws2]), ws1/assets/root-logo.png, ws2/assets/logo.png, and ws2/docs/manual.pdf:

  • include: ['assets/root-logo.png'] (primary workspace ws1):
    • Result: Read and returned inlineData (image/png).
  • include: ['assets/logo.png'] (secondary workspace ws2):
    • Result: isAssetExplicitlyRequested(['assets/logo.png'], '../ws2/assets/logo.png', logoPath) returns false.
    • Skipped: ../ws2/assets/logo.png (Reason: asset file (image/pdf/audio) was not explicitly requested by name or extension)
    • llmContent: ["No files matching the criteria were found or all were skipped."]
  • include: ['docs/*.pdf'] (secondary workspace ws2):
    • Skipped: ../ws2/docs/manual.pdf (Reason: asset file (image/pdf/audio) was not explicitly requested by name or extension)
  • include: ['<abs>/ws2/assets/logo.png'] (exact absolute path):
    • Skipped: ../ws2/assets/logo.png (Reason: asset file (image/pdf/audio) was not explicitly requested by name or extension)
What did you expect to happen?

Explicitly requested images, PDFs, and audio files in any configured workspace directory (or specified by absolute path) should be matched against each workspace directory's relative path (and the normalized absolute filePath), not solely against path.relative(targetDir, filePath)—while still rejecting generic wildcard globs like **/* or reports/**.

Client information
Client Information
  • Repository: google-gemini/gemini-cli (main at commit e5d88fb2c, package.json version 0.70.0-nightly.20261110.g1603e9bab)
  • Platform: macOS (darwin)
  • Node.js: v26.10.0
  • Reproduced locally via ReadManyFilesTool from @google/gemini-cli-core
Login information

N/A (reproduced directly against ReadManyFilesTool in @google/gemini-cli-core)

Anything else we need to know?

Regression introduced in #30211 (1930f2539), which fixed #29045. packages/core/src/tools/read-many-files.test.ts currently only tests isAssetExplicitlyRequested with primary-root relative paths (assets/logo.png) and tests multi-workspace reading with text files, so this case isn't covered yet.

Dominant language
TypeScript
Stars
109k
Forks
14.9k
Avg merge
1d 2h
Merged PRs (30d)
111

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google-gemini/gemini-cli

All issues in google-gemini/gemini-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.