fix: 避免 Codex 默认模型覆盖配置

This commit is contained in:
Codex
2026-05-29 16:27:26 +08:00
parent 0b388a2c5e
commit cfaebb4e8b
3 changed files with 46 additions and 4 deletions
+27
View File
@@ -4,6 +4,7 @@ const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity
const mode = process.env.AGENTRUN_FAKE_CODEX_MODE ?? "success";
let threadCounter = 0;
let turnCounter = 0;
let observedThreadModel = false;
for await (const line of rl) {
const trimmed = String(line).trim();
@@ -18,6 +19,15 @@ for await (const line of rl) {
continue;
}
if (message.method === "thread/start") {
observedThreadModel = Object.hasOwn(message.params ?? {}, "model");
if (mode === "reject-unexpected-model" && observedThreadModel) {
respond(message.id, null, { code: -32000, message: "thread/start unexpectedly included model" });
continue;
}
if (mode === "require-explicit-model" && message.params?.model !== "gpt-5.5") {
respond(message.id, null, { code: -32000, message: "thread/start did not include expected model" });
continue;
}
threadCounter += 1;
const thread = { id: `thread_selftest_${threadCounter}` };
notify("thread/started", { thread });
@@ -25,12 +35,29 @@ for await (const line of rl) {
continue;
}
if (message.method === "thread/resume") {
observedThreadModel = Object.hasOwn(message.params ?? {}, "model");
if (mode === "reject-unexpected-model" && observedThreadModel) {
respond(message.id, null, { code: -32000, message: "thread/resume unexpectedly included model" });
continue;
}
if (mode === "require-explicit-model" && message.params?.model !== "gpt-5.5") {
respond(message.id, null, { code: -32000, message: "thread/resume did not include expected model" });
continue;
}
const thread = { id: String(message.params?.threadId ?? "thread_selftest_resumed") };
notify("thread/started", { thread });
respond(message.id, { thread });
continue;
}
if (message.method === "turn/start") {
if (mode === "reject-unexpected-model" && (observedThreadModel || Object.hasOwn(message.params ?? {}, "model"))) {
respond(message.id, null, { code: -32000, message: "turn/start unexpectedly included model" });
continue;
}
if (mode === "require-explicit-model" && message.params?.model !== "gpt-5.5") {
respond(message.id, null, { code: -32000, message: "turn/start did not include expected model" });
continue;
}
if (mode === "missing-turn-result") {
respond(message.id, {});
continue;