























@@ -261,6 +261,7 @@ export async function startOrResumeThread(params: {
261261threadId: binding.threadId,
262262 authProfileId,
263263appServer: params.appServer,
264+dynamicTools: params.dynamicTools,
264265developerInstructions: params.developerInstructions,
265266config: resumeConfig,
266267nativeCodeModeEnabled: params.nativeCodeModeEnabled,
@@ -585,7 +586,9 @@ export function buildThreadStartParams(
585586nativeCodeModeOnlyEnabled: options.nativeCodeModeOnlyEnabled,
586587}),
587588 ...(options.nativeCodeModeEnabled === false ? { environments: [] } : {}),
588-developerInstructions: options.developerInstructions ?? buildDeveloperInstructions(params),
589+developerInstructions:
590+options.developerInstructions ??
591+buildDeveloperInstructions(params, { dynamicTools: options.dynamicTools }),
589592dynamicTools: options.dynamicTools,
590593experimentalRawEvents: true,
591594persistExtendedHistory: true,
@@ -598,6 +601,7 @@ export function buildThreadResumeParams(
598601threadId: string;
599602authProfileId?: string;
600603appServer: CodexAppServerRuntimeOptions;
604+dynamicTools?: CodexDynamicToolSpec[];
601605developerInstructions?: string;
602606config?: JsonObject;
603607nativeCodeModeEnabled?: boolean;
@@ -623,7 +627,9 @@ export function buildThreadResumeParams(
623627nativeCodeModeEnabled: options.nativeCodeModeEnabled,
624628nativeCodeModeOnlyEnabled: options.nativeCodeModeOnlyEnabled,
625629}),
626-developerInstructions: options.developerInstructions ?? buildDeveloperInstructions(params),
630+developerInstructions:
631+options.developerInstructions ??
632+buildDeveloperInstructions(params, { dynamicTools: options.dynamicTools }),
627633persistExtendedHistory: true,
628634};
629635}
@@ -820,13 +826,17 @@ function compareJsonFingerprint(left: JsonValue, right: JsonValue): number {
820826return JSON.stringify(left).localeCompare(JSON.stringify(right));
821827}
822828823-export function buildDeveloperInstructions(params: EmbeddedRunAttemptParams): string {
829+export function buildDeveloperInstructions(
830+params: EmbeddedRunAttemptParams,
831+options: { dynamicTools?: readonly CodexDynamicToolSpec[] } = {},
832+): string {
824833const nativeCommandGuidance = listRegisteredPluginAgentPromptGuidance({
825834surface: "codex_app_server",
826835includeLegacyGlobalGuidance: false,
827836}).join("\n");
828837const sections = [
829838"Running inside OpenClaw. Use OpenClaw dynamic tools for OpenClaw-owned messaging, cron, sessions, media, gateway, and nodes capabilities when available.",
839+buildDeferredDynamicToolManifest(options.dynamicTools),
830840"Use Codex native `spawn_agent` for Codex subagents. Use OpenClaw `sessions_spawn` only for OpenClaw or ACP delegation; if it is not already loaded, search for `sessions_spawn` in the `openclaw` dynamic tool namespace before calling it.",
831841buildVisibleReplyInstruction(params),
832842nativeCommandGuidance,
@@ -835,6 +845,23 @@ export function buildDeveloperInstructions(params: EmbeddedRunAttemptParams): st
835845return sections.filter((section) => typeof section === "string" && section.trim()).join("\n\n");
836846}
837847848+function buildDeferredDynamicToolManifest(
849+dynamicTools: readonly CodexDynamicToolSpec[] | undefined,
850+): string | undefined {
851+const deferredToolNames = [
852+ ...new Set(
853+(dynamicTools ?? [])
854+.filter((tool) => tool.deferLoading === true)
855+.map((tool) => tool.name.trim())
856+.filter(Boolean),
857+),
858+].toSorted((left, right) => left.localeCompare(right));
859+if (deferredToolNames.length === 0) {
860+return undefined;
861+}
862+return `Deferred searchable OpenClaw dynamic tools available: ${deferredToolNames.join(", ")}. Use \`tool_search\` to load exact callable specs before use.`;
863+}
864+838865function buildVisibleReplyInstruction(params: EmbeddedRunAttemptParams): string {
839866if (params.sourceReplyDeliveryMode === "message_tool_only") {
840867return "Preserve channel/session context. Visible channel replies: use `message`, do not describe would-reply.";
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。