-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Codex ignores its system prompt after the first message #900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@bolinfest I think this is the commit that introduces the regression: b323d10#diff-81c43c273518e6060612e02cf13bc1863785ee2316ce94ded66d624cf4621041L634-R692 |
@arnaudstiegler Based on what you pasted in the PR, I believe you are using the default version of the CLI, which is in TypeScript. The PR that you linked to is purely a Rust change, so I do not believe it could be related to this. How did you make that connection? |
You're right! I did observe the same behavior on the rust side, and I thought the reason was the change on the instruction logic:
I observe the same issue with both rust and the TS implementation |
Looking at codex/codex-cli/src/utils/agent/agent-loop.ts Line 730 in 55142e3
codex/codex-cli/src/utils/agent/agent-loop.ts Line 1112 in 55142e3
so I think this is a mistake in the Rust code, though given that they are sent for every turn in the TypeScript, I'm surprised you're seeing this issue there... |
Also, looking at #642 (which introduced the codex/codex-rs/core/src/codex.rs Lines 634 to 637 in 31d0d7a
|
…tions.md was empty (#908) I had seen issues where `codex-rs` would not always write files without me pressuring it to do so, and between that and the report of #900, I decided to look into this further. I found two serious issues with agent instructions: (1) We were only sending agent instructions on the first turn, but looking at the TypeScript code, we should be sending them on every turn. (2) There was a serious issue where the agent instructions were frequently lost: * The TypeScript CLI appears to keep writing `~/.codex/instructions.md`: https://github.com/openai/codex/blob/55142e3e6caddd1e613b71bcb89385ce5cc708bf/codex-cli/src/utils/config.ts#L586 * If `instructions.md` is present, the Rust CLI uses the contents of it INSTEAD OF the default prompt, even if `instructions.md` is empty: https://github.com/openai/codex/blob/55142e3e6caddd1e613b71bcb89385ce5cc708bf/codex-rs/core/src/config.rs#L202-L203 The combination of these two things means that I have been using `codex-rs` without these key instructions: https://github.com/openai/codex/blob/main/codex-rs/core/prompt.md Looking at the TypeScript code, it appears we should be concatenating these three items every time (if they exist): * `prompt.md` * `~/.codex/instructions.md` * nearest `AGENTS.md` This PR fixes things so that: * `Config.instructions` is `None` if `instructions.md` is empty * `Payload.instructions` is now `&'a str` instead of `Option<&'a String>` because we should always have _something_ to send * `Prompt` now has a `get_full_instructions()` helper that returns a `Cow<str>` that will always include the agent instructions first.
@arnaudstiegler if nothing else, this alerted me to a serious Rust issue, now fixed in #908, so thanks for that! |
Thanks for the fix! |
What version of Codex is running?
0.1.2504301751
Which model were you using?
o3
What platform is your computer?
Darwin 24.4.0 arm64 arm
What steps can reproduce the bug?
`
╭──────────────────────────────────────────────────────────────╮
│ ● OpenAI Codex (research preview) v0.1.2504301751 │
╰──────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────╮
│ localhost session: db26dfe84d514d62bbafaa469d78c4a5 │
│ ↳ workdir: ~/atlas-act-cli │
│ ↳ model: o3 │
│ ↳ provider: openai │
│ ↳ approval: suggest │
╰──────────────────────────────────────────────────────────────╯
user
As per your dev guidelines, how should you edit files?
user
What about grep?
`
What is the expected behavior?
No response
What do you see instead?
The system prompt clearly outlines that grep should not be used and only ripgrep should be used. Codex will answer correctly the question "Is grep allowed?" if it's the first message, but not for any subsequent message
Additional information
No response
The text was updated successfully, but these errors were encountered: