docs: add GPT-5 Codex guidelines for internal usage

- Added comprehensive instructions for Codex CLI harness, sandboxing, approvals, and editing constraints to `internal/misc/codex_instructions/`.
- Clarified `approval_policy` configurations and scenarios requiring escalated permissions.
- Provided detailed style and structure guidelines for presenting results in the Codex CLI.
This commit is contained in:
Luis Pater
2025-10-23 09:14:56 +08:00
parent d225558dae
commit e6d7677373
26 changed files with 3819 additions and 72 deletions

View File

@@ -96,8 +96,8 @@ func ConvertOpenAIRequestToCodex(modelName string, inputRawJSON []byte, stream b
// Extract system instructions from first system message (string or text object)
messages := gjson.GetBytes(rawJSON, "messages")
instructions := misc.CodexInstructions(modelName)
out, _ = sjson.SetRaw(out, "instructions", instructions)
_, instructions := misc.CodexInstructionsForModel(modelName, "")
out, _ = sjson.Set(out, "instructions", instructions)
// if messages.IsArray() {
// arr := messages.Array()
// for i := 0; i < len(arr); i++ {

View File

@@ -6,6 +6,7 @@ import (
"strings"
"github.com/router-for-me/CLIProxyAPI/v6/internal/misc"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -23,8 +24,6 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
rawJSON, _ = sjson.DeleteBytes(rawJSON, "temperature")
rawJSON, _ = sjson.DeleteBytes(rawJSON, "top_p")
instructions := misc.CodexInstructions(modelName)
originalInstructions := ""
originalInstructionsText := ""
originalInstructionsResult := gjson.GetBytes(rawJSON, "instructions")
@@ -33,6 +32,8 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
originalInstructionsText = originalInstructionsResult.String()
}
hasOfficialInstructions, instructions := misc.CodexInstructionsForModel(modelName, originalInstructionsResult.String())
inputResult := gjson.GetBytes(rawJSON, "input")
var inputResults []gjson.Result
if inputResult.Exists() {
@@ -70,10 +71,10 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
}
}
if instructions == originalInstructions {
if hasOfficialInstructions {
return rawJSON
}
// log.Debugf("instructions not matched, %s\n", originalInstructions)
log.Debugf("instructions not matched, %s\n", originalInstructions)
if len(inputResults) > 0 {
newInput := "[]"
@@ -98,7 +99,7 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
rawJSON, _ = sjson.SetRawBytes(rawJSON, "input", []byte(newInput))
}
rawJSON, _ = sjson.SetRawBytes(rawJSON, "instructions", []byte(instructions))
rawJSON, _ = sjson.SetBytes(rawJSON, "instructions", instructions)
return rawJSON
}