Skip to content

Conversation

@mosfor
Copy link

@mosfor mosfor commented Jan 3, 2026

Summary

Fixes #68 - The plugin was dropping custom instructions from AGENTS.md and other instruction files when using CODEX mode.

Problem

In CODEX mode, the plugin filters out the entire OpenCode system prompt and replaces it with a Codex-compatible bridge message. However, OpenCode appends custom instruction files (like AGENTS.md) directly into the system prompt. When the plugin filtered the prompt, it inadvertently dropped all custom instructions.

Solution

Implemented the fix proposed in issue #68:

  1. Extract: Parse the OpenCode system prompt for blocks starting with Instructions from:
  2. Filter: Remove the OpenCode prompt as before
  3. Re-insert: Add extracted instruction blocks as separate developer messages after the Codex bridge message

Changes

  • Added extractCustomInstructions() function to parse and extract instruction blocks
  • Modified filterOpenCodeSystemPrompts() to return both filtered input and extracted custom instructions
  • Updated transformRequestBody() to re-insert custom instructions after the bridge message
  • Added test case to verify custom instruction extraction works correctly

Testing

  • All 108 existing tests pass ✓
  • New test validates instruction extraction ✓
  • Build completes successfully ✓

Impact

Users can now use custom instructions from AGENTS.md, project-wide ./AGENTS.md, and other instruction files with CODEX mode without losing their configurations.

mosfor added 2 commits January 3, 2026 06:08
Fixes numman-ali#68

The plugin's request transformer was removing the entire OpenCode system
prompt in CODEX mode, which inadvertently dropped custom instructions from
AGENTS.md and other instruction files that OpenCode appends to the prompt.

Changes:
- Add extractCustomInstructions() to parse instruction blocks
- Modify filterOpenCodeSystemPrompts() to extract and return custom instructions
- Update transformRequestBody() to re-insert custom instructions after bridge message
- Add tests to verify custom instruction extraction works correctly

The fix extracts blocks starting with 'Instructions from:' before filtering
the OpenCode prompt, then re-inserts them as separate developer messages,
ensuring they are included in requests to the Codex API.
@numman-ali
Copy link
Owner

Closed by v4.3.0 (tag v4.3.0). Numman’s been busy, so I handled this on his behalf — thank you for your time and for the report. This was a tough job, but Sam Altman had my back getting it over the line.

Release: https://github.com/numman-ali/opencode-openai-codex-auth/releases/tag/v4.3.0
If you can, please follow and repost the release update on X: https://x.com/nummanali/status/2007975206711967764

@numman-ali numman-ali closed this Jan 5, 2026
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.

[BUG] Request transformer removes ~/.config/opencode/AGENTS.md

2 participants