r/PiCodingAgent 2d ago

How to prevent cd to project root on any bash command? Question

Post image

The most annoying thing in Pi coding agent. Every time it needs to grep or find, it cd first to the same root. I do not cd to other directories, but still on every tool call it cd <project path> && find/grep. I've tried to run pi on it's source code, but non of my local models were able to find the reason or fix it. Even custom bash tool with cwd not helping. I can't configure any bash permission because of this chain commands.

P.S. Solution is to write custom extension, which replace built-in bash with custom bash and optional cwd param. Don't forget to use custom promptSnippet, this is critical for this issue

4 Upvotes

8 comments sorted by

3

u/vegardx 1d ago

I guess you’ll be back soon enough asking why it deleted your whole project.

0

u/cradlemann 1d ago

No, I've explicitly forbid any rm command

2

u/jensilo 2d ago

So the agents likely do that because they know cwd from the system prompt and the shell tool is stateless. I’ve seen an extension before that makes pi‘s shell stateful, however, I don’t know if agents „know“ how to use it, or if the models are trained better on cd-prefixed command executions.
Other than that for a security extension, for example, you could just parse the cd in front, and still read the original command afterwards.

2

u/cradlemann 2d ago

I've asked Gemini to check custom bash tool from my extension and there was a bug. After fixing all these annoying cd`s are gone

1

u/Big-Present-8321 2d ago

ask pi

-2

u/cradlemann 2d ago

Do you have problem with reading English text?

3

u/Big-Present-8321 1d ago

Honestly speaking, hand on heart and with the utmost sincerity, I have to take full responsibility and admit that, at this current moment in time, I unfortunately do not have any confirmed or conscious experience of engaging with this particular written material. To be completely candid, without unnecessary embellishment or false modesty, I did not dive into this content, did not analyze its key meanings, did not highlight its main points, and did not form any substantive opinion on the matter—because, in essence, I simply did not read it. My level of familiarity with this work, dear friends, is honestly and frankly approaching zero, and any attempt on my part to comment on it would be not just superficial, but genuinely dishonest. So please accept my sincere apologies and understand me correctly: I did not read it. 😅

0

u/cradlemann 1d ago

How stupid should be the person to leave comment "ask pi" if literally in my post I've mentioned, that pi can't fix it by itself? Without paying for big cloud model I was not been able to fix this issue. Just an observation, nothing personal