#Agent mode keeps forgetting what directory it is currently in

5 messages · Page 1 of 1 (latest)

rough herald
#

I've been pushing agent mode a bit harder now that it seems more experienced. I've been impressed, but I've noticed that it keeps forgetting what directory it's in as it navigates around the project creating files. This is what typically happens:

  • It runs a command, correctly cd-ing into the appropriate directory
  • It runs the next command, assuming it's in the directory where the prompt started
  • It realizes it's in the wrong directory and tries to reorient. Or worse, it succeeds at creating a file in some nested path and falsely assumes it's in the right directory! I've had it create files in packages/backend/packages/backend/ when this occurs
hazy havenBOT
#

Hi @rough herald. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

I understand your frustration with Agent Mode getting confused about the current directory. This is a known issue with how terminals and shells handle directory tracking, and it's not specific to Warp's Agent Mode.

Based on the knowledge sources, this behavior is related to how Unix-based systems handle directory paths. When a directory is deleted and recreated (which can happen during file operations), the shell can get confused because it's still referencing the old directory identifier internally, even though the path looks the same.

As explained in a GitHub issue:

The current directory, while represented visually to you as a file path, is actually internally represented by a unique identifier for the working directory. When you delete and recreate the folder at a given path, the shell is still actually within the old working directory. GitHub Issue #2883

This is standard Unix behavior and would happen in any terminal, not just Warp.

Workarounds

The most reliable workaround is to use the cd command to reorient after operations that might affect the directory structure:

  1. Use cd .. followed by cd back/to/directory to refresh the shell's understanding of the current directory
  2. Or simply use cd . to refresh the current directory reference

This forces the shell to re-evaluate the directory structure and update its internal reference.

For Agent Mode specifically, you might want to:

  1. Start new conversations for distinct tasks to avoid confusion in long conversations
  2. Attach relevant context blocks to your queries using the context attachment feature (CMD+UP/DOWN on macOS or CTRL+UP/DOWN on Windows/Linux) Conversations with Agent Mode
#

If you continue experiencing this issue, you might want to report it specifically for Agent Mode on the Warp GitHub issues page.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@rough herald Kapa.ai is still learning and improving, please let me know how I did by reacting below.