Tool Invocation by LLM return empty results
What version of Codex is running?
0.31.0
Which model were you using?
gpt-5
What platform is your computer?
Linux 6.11.0-1013-gcp x86_64 x86_64
What steps can reproduce the bug?
From my cloned github respository root, I open codex on the terminal.
Then I prompt to list the directory contents and I get:
▌Can you list the contents of the present directory?
Listing files in the current workspace directory.
• Explored
└ List ls -la
• Ran pwd && ls -la
The current directory /home/dschao/wlt appears to be empty. No files or folders found. Do you
want me to initialize a project here or pull an existing repo?
I am remote ssh'd into a GCP VM.
<img width="1806" height="701" alt="Image" src="https://github.com/user-attachments/assets/cdd6b199-6168-4721-96dd-72583c8f33d8" />
Also attaching logs with export RUST_LOG="warn,codex_core=trace,codex_tui=trace".
What is the expected behavior?
It should be able to list my directory - there are many files and directories...
What do you see instead?
It seems to think ls -la returns empty.
Additional information
I am ssh'd into a GCP VM.
On my Mac it all works.
Claude Code works on the same VM.
6 Comments
Sorry to just pop in, but I'm diagnosing some problems and I wandered into your output thinking it might be related (it's not) but I think the problem you're seeing is something I've seen before (related to mount points on a WSL 2 distro). Look at this message: "^[[2m2025-09-09T22:26:53.488619Z^[[". Where you're asking ls to be run is outside of your workspace.
It looks to me like Codex is executing ls (returns exit code 0) but because it's outside of the workspace it "redacts" it. I'll leave it to an expert, I just took a very quick look (trying to help but I could be wrong). I think what's going on should be clearer (it should definitely and quickly fail), but I don't think that what you requested "should work".
I imagine it is something to do with not being in the workspace... but I feel that my use of it suggest that I ought to be there:
Let me know if I can try some other commands that could be helpful to you.
Apologies if I lead you astray, I'm just a random guy that looked at this, hopefully being helpful. I sent you the wrong timestamp based on a find error, apologies. The actual timestamp I saw that made me say "that looks weird" is: 2m2025-09-09T22:27:05.937970Z
There is a lot going on there that I don't understand, but things I saw that made me say "weird":
I'm not an expert but I'd:
codex --sandbox danger-full-accessjust to see if "running unsandboxed" changes your output, my guess is that this will work and will prove that ls output is being obfuscated because of sandbox policyI think there are bugs represented in the logs (2 prompts generating 1MB of logging with the full system prompt repeated dozens of times seems "suboptimal"), but I think that your root issue is related to sandbox policy and "path misdirection".
No problem at all! Thanks so much for your insights @mwcrutcher :)
codex --sandbox danger-full-access
also didn't work. I'll just have to dig around some more... or maybe someone here will beat me to it.
For anyone running into this problem, here is my case
The Codex cli always runs commands by calling:
bash -lc "your command"
(for example, bash -lc "ls -la" or bash -lc "pwd").
If you’re using fish (or any shell other than bash) as your main shell, this can break if your ~/.bash_profile or ~/.bashrc forces bash to immediately exec into another shell. In my case, my ~/.bash_profile looked like this:
Because of the exec /bin/zsh -l, bash never actually ran the command — it just switched over to zsh and stopped, causing empty output for codex cli
Fix:
Check your ~/.bash_profile or ~/.bashrc for any lines like exec /bin/zsh -l (or exec fish -l) and remove them. After I removed that line, Codex worked perfectly again, even though my main shell is still fish.
Billiant @minhluuquang - great observation on the
bash -lc!Indeed, that was my problem too.
In my case, I still had to do the
exec /bin/zsh -lfor other reasons... so I ended up doing a hacky thing (thank you GPT for this hint too):Basically... only when we are in a login shell, in interactive mode, and not executing under
bash -cdo we run exec. This covers my ssh login case, but let codex use bash -c.