-
fix: agent instructions were not being included when ~/.codex/instructions.md was empty (#908)
发布于
2025-05-13 00:24:44 +00:00 I had seen issues where
codex-rswould not always write files without
me pressuring it to do so, and between that and the report of
https://github.com/openai/codex/issues/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/d665181a1f442254e1a47733e72d9bc27283ba75/codex-cli/src/utils/config.ts#L586 - If
instructions.mdis present, the Rust CLI uses the contents of it
INSTEAD OF the default prompt, even ifinstructions.mdis empty:
https://github.com/openai/codex/blob/d665181a1f442254e1a47733e72d9bc27283ba75/codex-rs/core/src/config.rs#L202-L203
The combination of these two things means that I have been using
codex-rswithout these key instructions:
https://github.com/openai/codex/blob/main/codex-rs/core/prompt.mdLooking 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.instructionsisNoneifinstructions.mdis emptyPayload.instructionsis now&'a strinstead ofOption<&'a String>because we should always have something to sendPromptnow has aget_full_instructions()helper that returns a
Cow<str>that will always include the agent instructions first.
下载附件
- The TypeScript CLI appears to keep writing