Show working directory before saving files
I had an agent running and told it to make some edits in another folder. It used cd, then I told it to write some files to its own workspace but both it and I forgot that it had cd'd away from its workspace. Perhaps showing the current working directory on each file save prompt could be useful?
Anthropic has suggested that the solution to this is to always use absolute paths...
While building our agent for SWE-bench, we actually spent more time optimizing our tools than the overall prompt. For example, we found that the model would make mistakes with tools using relative filepaths after the agent had moved out of the root directory. To fix this, we changed the tool to always require absolute filepaths—and we found that the model used this method flawlessly.
I've considered adding it to the system prompt and optimizing for such use by returning full paths wherever we provide one.
I now mention a preference for absolute paths it in the system prompt: https://github.com/ErikBjare/gptme/commit/ba11552a7d6febd36223a4e35e438e777646b226
Some tools should probably be updated to return absolute paths instead of relative ones.
Maybe also inject the current working directory in a ephemeral context message (we used to do something like this) before the last user/assistant message so that it can easily/reliably construct correct paths from relative dir output (like ls, find).
The shell tool now outputs a line about any working directory change after running a command: https://github.com/gptme/gptme/pull/534
This significantly improved things. I suppose it's wasn't prompted well enough about the statefulness of path changes (might think its a subshell, for example), this makes it clear.