bug: non-interactive mode is flaky and produces duplicate JSON output
What version of Codex is running?
0.1.2504221401
Which model were you using?
gpt-4o-mini
What platform is your computer?
Darwin 24.4.0 arm64 arm
What steps can reproduce the bug?
Flaky Behavior:
Running the same exact command multiple times results in inconsistent behavior:
- Sometimes it succeeds and returns the expected output.
- Sometimes it fails with the error:
"I currently can't access the codebase to identify specific lines in the Rust files. If you could share the relevant Rust code or files, I can analyze them and provide you with the targeted lines as per your criteria."
- Sometimes it returns empty output.
I did not change anything between runs (same working directory, same prompt).
Duplicate JSON Objects in the Output:
In non-interactive mode, the output is a stream of JSON objects but many of these objects are exact duplicates.
Example output:
{"id":"msg_","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"It seems I'm unable to run commands to explore the current directory or read files directly due to some restrictions. However, if you have a specific file or piece of code you want me to explain, please let me know the filename or share the code here! I'm eager to help with any questions you have about it."}],"role":"assistant"}
{"id":"msg_","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"It seems I'm unable to run commands to explore the current directory or read files directly due to some restrictions. However, if you have a specific file or piece of code you want me to explain, please let me know the filename or share the code here! I'm eager to help with any questions you have about it."}],"role":"assistant"}
{"id":"msg_","type":"message","status":"completed","content":[{"type":"output_text","annotations":[],"text":"It seems I'm unable to run commands to explore the current directory or read files directly due to some restrictions. However, if you have a specific file or piece of code you want me to explain, please let me know the filename or share the code here! I'm eager to help with any questions you have about it."}],"role":"assistant"}
Hard to Isolate the Final Answer:
When using non-interactive mode, the output includes a lot of intermediate JSON objects before reaching the final answer.
I tried setting CODEX_QUIET_MODE=1 but it didn't make a noticeable difference.
Ideally, there should be a way to suppress all intermediate JSON objects and only return the final assistant message.
What is the expected behavior?
_No response_
What do you see instead?
_No response_
Additional information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗