- 模型感知 instructions:刷新 instructions.txt 至最新 GPT-5-Codex prompt,新增 GPT-5.1 / GPT-5.2 真实 Codex 编码 agent prompt;新增 openai.CodexBaseInstructionsForModel 按模型选用(codex 系→GPT-5-Codex,gpt-5.2→GPT-5.2,gpt-5.1/gpt-5→GPT-5.1), defaultCodexSynthInstructions 改为按 model 选择 - client_metadata:OAuth /responses 请求用账号真实 openai_device_id 注入 client_metadata["x-codex-installation-id"];加法式、幂等、不覆盖既有项, 无 device_id(非 OAuth 账号)则不写入、不伪造 - anthropic 转换补全 SSE 事件 reasoning_text.delta 与 custom_tool_call_input.delta (含 custom_tool_call item 注册为 tool_use),与 chat completions 路径对齐 - 新增单元测试覆盖以上行为(apicompat / openai / service) 承接上一提交,仍为加法式改进,不改动既有可工作的请求头。
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package openai
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func firstLine(s string) string {
|
|
s = strings.TrimSpace(s)
|
|
if i := strings.IndexByte(s, '\n'); i >= 0 {
|
|
return s[:i]
|
|
}
|
|
return s
|
|
}
|
|
|
|
// CodexBaseInstructionsForModel 应按模型返回对应的真实 Codex base prompt。
|
|
func TestCodexBaseInstructionsForModel(t *testing.T) {
|
|
cases := []struct {
|
|
model string
|
|
wantHead string
|
|
}{
|
|
{"gpt-5-codex", "You are Codex, based on GPT-5"},
|
|
{"gpt-5.3-codex", "You are Codex, based on GPT-5"},
|
|
{"gpt-5.3-codex-spark", "You are Codex, based on GPT-5"},
|
|
{"gpt-5.1-codex-max", "You are Codex, based on GPT-5"},
|
|
{"gpt-5.2-codex", "You are Codex, based on GPT-5"},
|
|
{"gpt-5.2", "You are GPT-5.2 running in the Codex CLI"},
|
|
{"gpt-5.1", "You are GPT-5.1 running in the Codex CLI"},
|
|
{"gpt-5", "You are GPT-5.1 running in the Codex CLI"},
|
|
{"", "You are Codex, based on GPT-5"}, // 回退
|
|
}
|
|
for _, c := range cases {
|
|
got := strings.TrimSpace(CodexBaseInstructionsForModel(c.model))
|
|
if got == "" {
|
|
t.Errorf("model %q: got empty instructions", c.model)
|
|
continue
|
|
}
|
|
if !strings.HasPrefix(got, c.wantHead) {
|
|
t.Errorf("model %q: got prefix %q, want %q", c.model, firstLine(got), c.wantHead)
|
|
}
|
|
}
|
|
}
|