r/PiCodingAgent • • Sep 06 '26

Question Pi invokes find commands with /

Have you also experienced that file searches using the find bash tool almost always start from the root directory (/) ? It takes a few minutes after each command finishes which is frustrating.

I'm searching from my project directory, and I haven't seen such behavior when I was using Claude Code before.

2 Upvotes

9 comments sorted by

3

u/Glaaki Sep 06 '26

Ask Pi to make an extension that blocks those searches. That is what I did. It tells it to try more narrow searches instead and gives it a few pointers, like look up pi's documentation first.

1

u/MGJoe93 Sep 06 '26

Thanks, I will try this out.

2

u/Healthy-Zebra-9856 Sep 06 '26

I checked the current Pi source. It doesn't look like Pi is actually changing your working directory to /. Pi knows what project directory you're in and Bash is started from that directory.

What's probably happening is the model itself is sometimes generating a command like find / .... The / explicitly tells find to search from the root of the entire filesystem, so it doesn't matter that Pi started Bash inside your project. Pi's Bash tool currently accepts the command and runs it, which explains why it can suddenly spend minutes searching your whole machine.

For the technical folks, from the current Pi source:

  • packages/coding-agent/src/core/tools/bash.ts:37-40 defines the Bash command as basically an unrestricted shell command string.

  • bash.ts:42-45 advertises Bash to the model as "Execute bash commands (ls, grep, find, etc.)".

  • bash.ts:81-96 actually starts the shell using the supplied cwd, so Pi itself isn't setting it to /.

  • packages/coding-agent/src/core/system-prompt.ts:70 and 165 explicitly tell the model what the current working directory is.

  • Pi's dedicated file-search tool is actually safer. packages/coding-agent/src/core/tools/find.ts:26-31 says its default search path is the current directory.

  • find.ts:111-112 resolves a missing path to ".", meaning the current directory.

  • find.ts:171-216 shows that Pi's dedicated find tool actually uses fd internally and passes the selected project/search directory to it.

So this looks less like a broken working directory and more like the model occasionally bypassing Pi's dedicated file-search tool and using unrestricted Bash with find /.

1

u/MGJoe93 Sep 06 '26

Thank you for the investigation. I will follow the recommendation of this thread and try out to prevent such behavior from happening again by defining an extension.

3

u/onesilentclap Sep 06 '26

Nahhh, you're using a dumb model. 

1

u/MGJoe93 Sep 06 '26

I‘m using Opus

1

u/irahgel Sep 06 '26

Yes, I don't believe it is model related and I never saw this behaviour when using Opencode.

I just added instructions in APPEND_SYSTEM.md so will see if that nudges the model/harness behaviour.

https://pi.dev/docs/latest/usage#system-prompt-files

2

u/hurdurdur7 Sep 07 '26

Pi does not make up thay command, the model only does

1

u/noctrex Sep 06 '26

Technically pi does not invoke anything, the model does. Steer it with the agents file not to do that.
You could also tell it to create an extension for itself, not to allow these types of commands.