fix: 避免 Codex 默认模型覆盖配置
This commit is contained in:
@@ -311,13 +311,13 @@ export async function runCodexStdioTurn(options: CodexStdioTurnOptions): Promise
|
||||
|
||||
const threadMethod = options.threadId ? "thread/resume" : "thread/start";
|
||||
const threadParams: JsonRecord = options.threadId
|
||||
? { threadId: options.threadId, model: options.model ?? "default", cwd: options.cwd, approvalPolicy: options.approvalPolicy, sandbox: options.sandbox }
|
||||
: { model: options.model ?? "default", cwd: options.cwd, approvalPolicy: options.approvalPolicy, sandbox: options.sandbox, serviceName: "agentrun" };
|
||||
? withOptionalModel({ threadId: options.threadId, cwd: options.cwd, approvalPolicy: options.approvalPolicy, sandbox: options.sandbox }, options.model)
|
||||
: withOptionalModel({ cwd: options.cwd, approvalPolicy: options.approvalPolicy, sandbox: options.sandbox, serviceName: "agentrun" }, options.model);
|
||||
const threadResponse = requireResponseRecord(await client.request(threadMethod, threadParams, requestTimeoutMs), threadMethod);
|
||||
threadId = requireNestedId(threadResponse, threadMethod, "thread");
|
||||
events.push({ type: "backend_status", payload: { phase: `${threadMethod}:completed`, threadId } });
|
||||
|
||||
const turnResponse = requireResponseRecord(await client.request("turn/start", { threadId, input: textInput(options.prompt), cwd: options.cwd, approvalPolicy: options.approvalPolicy, model: options.model ?? "default" }, requestTimeoutMs), "turn/start");
|
||||
const turnResponse = requireResponseRecord(await client.request("turn/start", withOptionalModel({ threadId, input: textInput(options.prompt), cwd: options.cwd, approvalPolicy: options.approvalPolicy }, options.model), requestTimeoutMs), "turn/start");
|
||||
turnId = requireNestedId(turnResponse, "turn/start", "turn");
|
||||
events.push({ type: "backend_status", payload: { phase: "turn/start:completed", turnId } });
|
||||
|
||||
@@ -450,6 +450,12 @@ function terminalStatusFromValue(value: unknown): TerminalStatus {
|
||||
return "failed";
|
||||
}
|
||||
|
||||
function withOptionalModel(params: JsonRecord, model: string | undefined): JsonRecord {
|
||||
const value = typeof model === "string" ? model.trim() : "";
|
||||
if (!value) return params;
|
||||
return { ...params, model: value };
|
||||
}
|
||||
|
||||
function childEnv(options: CodexStdioTurnOptions, codexHome: string): NodeJS.ProcessEnv {
|
||||
return {
|
||||
...process.env,
|
||||
|
||||
Reference in New Issue
Block a user