[PR #8357] fix(session): skip duplicate system prompt for Codex OAuth sessions #12717

Closed
opened 2026-02-16 18:17:36 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8357

State: closed
Merged: Yes


What does this PR do?

Fixes #8354

For Codex OAuth sessions using GPT-5, the same ~300-line prompt content was being sent twice:

  1. In the instructions API parameter (from codex_header.txt)
  2. As the first user message (from codex.txt)

This wasted ~5K tokens per request since both files contain effectively identical content (only trailing whitespace differences).

Changes:

  • Move isCodex detection earlier (before building the system array)
  • Skip SystemPrompt.provider() for Codex sessions since the prompt is already included via options.instructions
  • Parallelize the provider/auth fetches with language/config fetch for better performance
  • Reuse already-fetched provider variable instead of re-calling Provider.getProvider() in the plugin trigger

How did you verify your code works?

  • Reviewed the code path described in the issue
  • Verified that codex_header.txt and codex.txt are identical (as stated in the issue)
  • Confirmed that the instructions parameter carries the same content that would otherwise be included via SystemPrompt.provider() for GPT-5 models

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8357 **State:** closed **Merged:** Yes --- ### What does this PR do? Fixes #8354 For Codex OAuth sessions using GPT-5, the same ~300-line prompt content was being sent twice: 1. In the `instructions` API parameter (from `codex_header.txt`) 2. As the first user message (from `codex.txt`) This wasted ~5K tokens per request since both files contain effectively identical content (only trailing whitespace differences). **Changes:** - Move `isCodex` detection earlier (before building the system array) - Skip `SystemPrompt.provider()` for Codex sessions since the prompt is already included via `options.instructions` - Parallelize the provider/auth fetches with language/config fetch for better performance - Reuse already-fetched `provider` variable instead of re-calling `Provider.getProvider()` in the plugin trigger ### How did you verify your code works? - Reviewed the code path described in the issue - Verified that `codex_header.txt` and `codex.txt` are identical (as stated in the issue) - Confirmed that the `instructions` parameter carries the same content that would otherwise be included via `SystemPrompt.provider()` for GPT-5 models --- 🤖 Generated with Claude Code
yindo added the pull-request label 2026-02-16 18:17:36 -05:00
yindo closed this issue 2026-02-16 18:17:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12717