




















@@ -97,25 +97,19 @@ export async function startOrResumeThread(params: {
9797}
9898}
9999100-const modelProvider = resolveCodexAppServerModelProvider(params.params.provider);
101100const response = assertCodexThreadStartResponse(
102-await params.client.request("thread/start", {
103-model: params.params.modelId,
104- ...(modelProvider ? { modelProvider } : {}),
105-cwd: params.cwd,
106-approvalPolicy: params.appServer.approvalPolicy,
107-approvalsReviewer: params.appServer.approvalsReviewer,
108-sandbox: params.appServer.sandbox,
109- ...(params.appServer.serviceTier ? { serviceTier: params.appServer.serviceTier } : {}),
110-serviceName: "OpenClaw",
111- ...(params.config ? { config: params.config } : {}),
112-developerInstructions:
113-params.developerInstructions ?? buildDeveloperInstructions(params.params),
114-dynamicTools: params.dynamicTools,
115-experimentalRawEvents: true,
116-persistExtendedHistory: true,
117-} satisfies CodexThreadStartParams),
101+await params.client.request(
102+"thread/start",
103+buildThreadStartParams(params.params, {
104+cwd: params.cwd,
105+dynamicTools: params.dynamicTools,
106+appServer: params.appServer,
107+developerInstructions: params.developerInstructions,
108+config: params.config,
109+}),
110+),
118111);
112+const modelProvider = resolveCodexAppServerModelProvider(params.params.provider);
119113const createdAt = new Date().toISOString();
120114await writeCodexAppServerBinding(params.params.sessionFile, {
121115threadId: response.thread.id,
@@ -140,6 +134,34 @@ export async function startOrResumeThread(params: {
140134};
141135}
142136137+export function buildThreadStartParams(
138+params: EmbeddedRunAttemptParams,
139+options: {
140+cwd: string;
141+dynamicTools: CodexDynamicToolSpec[];
142+appServer: CodexAppServerRuntimeOptions;
143+developerInstructions?: string;
144+config?: JsonObject;
145+},
146+): CodexThreadStartParams {
147+const modelProvider = resolveCodexAppServerModelProvider(params.provider);
148+return {
149+model: params.modelId,
150+ ...(modelProvider ? { modelProvider } : {}),
151+cwd: options.cwd,
152+approvalPolicy: options.appServer.approvalPolicy,
153+approvalsReviewer: options.appServer.approvalsReviewer,
154+sandbox: options.appServer.sandbox,
155+ ...(options.appServer.serviceTier ? { serviceTier: options.appServer.serviceTier } : {}),
156+serviceName: "OpenClaw",
157+ ...(options.config ? { config: options.config } : {}),
158+developerInstructions: options.developerInstructions ?? buildDeveloperInstructions(params),
159+dynamicTools: options.dynamicTools,
160+experimentalRawEvents: true,
161+persistExtendedHistory: true,
162+};
163+}
164+143165export function buildThreadResumeParams(
144166params: EmbeddedRunAttemptParams,
145167options: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。