Skip to content

fix: when using codex sub, send the custom agent prompts as a separate developer message (previously sent as user message but api allows for instructions AND developer messages)#11667

Merged
rekram1-node merged 2 commits intodevfrom
fix-codex-system
Feb 1, 2026

Conversation

@rekram1-node
Copy link
Collaborator

@rekram1-node rekram1-node commented Feb 1, 2026

fixes: #11163

credit to @CarlosCommits for finding

rekram1-node and others added 2 commits February 1, 2026 14:53
…e developer message (previously sent as user message but api allows for instructions AND developer messages)
@rekram1-node rekram1-node merged commit ec72014 into dev Feb 1, 2026
5 checks passed
@rekram1-node rekram1-node deleted the fix-codex-system branch February 1, 2026 20:57
@CarlosCommits
Copy link
Contributor

Thanks for the credit for finding the issue, but I think with this new solution OAuth Codex behavior is still different from non-OAuth Codex:

OAuth Codex path

Non-OAuth Codex (Zen/opencode)

Resulting behavior:

  • OAuth Codex keeps PROMPT_CODEX (via options.instructions) and appends custom agent prompt + env/AGENTS as system/developer messages.
  • Non-OAuth Codex REPLACES the PROMPT_CODEX with agent.prompt when present.

So behavior still differs (append vs replace). Assumning parity is desired, we likely need to either:

  1. For OAuth: set options.instructions to agent.prompt ?? PROMPT_CODEX and append input.system, or
  2. For non-OAuth: always include base prompt even when agent prompt is present.

Also input.system is env + AGENTS.md: packages/opencode/src/session/prompt.ts line 605
https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/session/prompt.ts#L605

@rekram1-node
Copy link
Collaborator Author

yeah this is expected from what openai told me.

If you are using a codex sub the instructions field should always be that codex prompt and then anything custom should be sent as a developer message (system message) separately

If you arent using a codex sub the all that instructions stuff is moot

@rekram1-node
Copy link
Collaborator Author

does that make sense? Am i missing something?

@CarlosCommits
Copy link
Contributor

I might be missing something. If OpenAI recommends PROMPT_CODEX for the Codex model, why only enforce it for OAuth Codex?

Why not apply the same rule to all Codex instances (including Zen/non‑OAuth)?

Right now behavior differs:

  • 5.2 Codex via Zen + custom agent --> PROMPT_CODEX is replaced by agent prompt.
  • 5.2 Codex via OAuth + custom agent --> PROMPT_CODEX remains and agent prompt is appended.

Is this intentional?

@rekram1-node
Copy link
Collaborator Author

sorry it is a requirement for oauth flow thats what im saying

@rekram1-node
Copy link
Collaborator Author

rekram1-node commented Feb 1, 2026

yes this is intentional (it’s a requirement from them they asked me to do)

and its only for the codex subscription

@CarlosCommits
Copy link
Contributor

Oh that's interesting, thanks for clarifying. I guess that makes it more difficult to use oauth codex for custom agents, since there is a baked in default that we can't remove.

kiennq pushed a commit to kiennq/opencode that referenced this pull request Feb 2, 2026
…e developer message (previously sent as user message but api allows for instructions AND developer messages) (anomalyco#11667)

Co-authored-by: Carlos <carloscanas942@gmail.com>
ishaksebsib pushed a commit to ishaksebsib/opencode that referenced this pull request Feb 4, 2026
…e developer message (previously sent as user message but api allows for instructions AND developer messages) (anomalyco#11667)

Co-authored-by: Carlos <carloscanas942@gmail.com>
ishaksebsib pushed a commit to ishaksebsib/opencode that referenced this pull request Feb 4, 2026
…e developer message (previously sent as user message but api allows for instructions AND developer messages) (anomalyco#11667)

Co-authored-by: Carlos <carloscanas942@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI oauth 5.2 codex model is not injecting system prompt for agent persona

2 participants