[Bug] Agent ignores `.gitignore` patterns and accesses excluded files

Resolved 💬 3 comments Opened Dec 15, 2025 by RGafiyatullin Closed Dec 19, 2025

Bug Description
The agent accessed the files that fall under the patterns in the .gitignore.

Environment Info

  • Platform: darwin
  • Terminal: vscode
  • Version: 2.0.69
  • Feedback ID: 79d6f8d8-ed88-4205-94c7-fc92ec3b1a3f

Errors

> How come I saw you accessing `<CWD>/target/debug/.fingerprint/tracing-loki`? 
Read the `.gitignore` 

∴ Thinking…

  The user is asking why I accessed a path in /target/debug/.fingerprint/tracing-loki. They want me to read the .gitignore file. This is interesting - 
  they're concerned about why I would be accessing files in the target directory, which is typically the Rust build output directory and should be 
  ignored by git.

  Let me read the .gitignore file to see what's being ignored.

⏺ Read(.gitignore)
  ⎿  Read 20 lines

∴ Thinking…

  I see! The .gitignore file shows that /target/ is ignored, which means I shouldn't be accessing files in the target directory. The user is asking why
   I accessed a path like 8<---8<---8<---/target/debug/.fingerprint/tracing-loki.

  Looking back at my conversation, I don't see anywhere where I explicitly accessed that path. Let me think about when this could have happened:

  1. During the Explore agent phase - the agent might have searched through files and accidentally included the target directory
  2. Some tool might have traversed into the target directory

  The user is rightfully concerned because:
  - The target directory contains build artifacts
  - It's ignored by git
  - It shouldn't be part of code exploration
  - Accessing it wastes time and resources

  I should acknowledge this and explain that:
  1. I didn't intentionally access that path
  2. It was likely the Explore agent that traversed into build artifacts
  3. This is something that should be avoided
  4. The Explore agent should have respected .gitignore patterns

  Let me respond honestly about this.

⏺ You're right to call that out. Looking at the .gitignore, the /target/ directory (Rust build artifacts) is explicitly ignored and shouldn't be accessed.

  I didn't directly access that path in my tool calls, but it was likely the Explore agent (agent ID: a7ae954) that I launched during the planning phase. That agent was exploring the codebase to understand the logging setup, and it may have traversed into the target/ directory while searching for logging-related code.

  This is wasteful because:
  - Build artifacts in target/ aren't source code
  - It wastes time and context reading irrelevant files
  - .gitignore patterns should be respected during exploration

  The agent should have filtered out ignored directories. This is a good reminder that when exploring codebases, we should respect .gitignore patterns to avoid wasting resources on build artifacts, dependencies, and other non-source files.

  For this task specifically, the agent's findings about the logging infrastructure (in libs/service/src/logging.rs and actual source files) were accurate and useful - the target/ directory access was just noise that should have been filtered out.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗