Model is using `rg` wrong when searching for multiple patterns at the same time.

Resolved 💬 1 comment Opened Nov 14, 2025 by CarloWood Closed Dec 1, 2025

What version of Codex is running?

codex-cli 0.0.0 (output of codex --version)... actual version: 0.58.0

What subscription do you have?

Plus

Which model were you using?

gpt-5.1-codex

What platform is your computer?

Linux 6.17.7-arch1-1 x86_64 unknown

What issue are you seeing?

The model did run the shell command bash -lc 'rg -n "struct TurnContext" -n "TurnContext" codex-rs/core/src -g"*.rs"', which by the way is shown wrongly in the CLI terminal as:

• Ran "bash -lc 'rg -n \"struct TurnContext\" -n \"TurnContext\" codex-rs/core/src -g\"*.rs\"'"

Even though this interface puts double quotes around "bash ... ", those are not shell quotes. The real OUTER shell quotes are the singe quotes around the rg command, and as such the double quotes inside of that should not be escaped.

Anyway - this command is wrong: instead of repeating -n, it should have prefixed every pattern with -e.
For the above the correct command is:

bash -lc 'rg -n -e "struct TurnContext" -e "TurnContext" codex-rs/core/src -g"*.rs"'

What it executed now returns in the OS error "rg: TurnContext: No such file or directory (os error 2)", which was completely ignored by the model; apparently oblivious that it made an error and simply assuming that there is no pattern 'TurnContext' in the code (only "struct TurnContext").

What steps can reproduce the bug?

Uploaded thread: 019a8365-5d09-7bc3-97d9-7922760069b9

What is the expected behavior?

The model should know how to use rg, or at the very least correct itself if an error occurs.

Additional information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗