fix(openai): default GPT-5 prompt overlay

This commit is contained in:
Peter Steinberger
2026-04-21 02:28:44 +01:00
parent b6a8759b29
commit ab03d4e037
4 changed files with 31 additions and 10 deletions

View File

@@ -15,6 +15,7 @@ import {
OPENAI_GPT5_EXECUTION_BIAS,
OPENAI_GPT5_OUTPUT_CONTRACT,
OPENAI_GPT5_TOOL_CALL_STYLE,
shouldApplyOpenAIPromptOverlay,
} from "./prompt-overlay.js";
const runtimeMocks = vi.hoisted(() => ({
@@ -414,12 +415,30 @@ describe("openai plugin", () => {
execution_bias: OPENAI_GPT5_EXECUTION_BIAS,
},
});
expect(
openaiProvider.resolveSystemPromptContribution?.({
...contributionContext,
modelId: "openai/gpt-5.4-mini",
}),
).toEqual({
stablePrefix: [OPENAI_GPT5_OUTPUT_CONTRACT, OPENAI_GPT5_TOOL_CALL_STYLE].join("\n\n"),
sectionOverrides: {
interaction_style: OPENAI_FRIENDLY_PROMPT_OVERLAY,
execution_bias: OPENAI_GPT5_EXECUTION_BIAS,
},
});
expect(
openaiProvider.resolveSystemPromptContribution?.({
...contributionContext,
modelId: "gpt-image-1",
}),
).toBeUndefined();
expect(shouldApplyOpenAIPromptOverlay({ modelProviderId: "openai", modelId: "gpt-4.1" })).toBe(
false,
);
expect(
shouldApplyOpenAIPromptOverlay({ modelProviderId: "anthropic", modelId: "gpt-5.4" }),
).toBe(false);
});
it("includes stronger execution guidance in the OpenAI prompt overlay", () => {

View File

@@ -52,7 +52,7 @@
"type": "string",
"enum": ["friendly", "on", "off"],
"default": "friendly",
"description": "Controls the default OpenAI-specific personality used for OpenAI and OpenAI Codex runs. `friendly` and `on` enable the overlay; `off` disables it."
"description": "Controls the OpenAI-specific friendly interaction-style overlay for GPT-5 OpenAI and OpenAI Codex runs. `friendly` and `on` enable the style overlay; `off` disables only that style layer."
}
}
}

View File

@@ -1,7 +1,7 @@
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
const OPENAI_PROVIDER_IDS = new Set(["openai", "openai-codex"]);
const OPENAI_GPT5_MODEL_PREFIX = "gpt-5";
const OPENAI_GPT5_MODEL_ID_PATTERN = /(?:^|[/:])gpt-5(?:[.-]|$)/i;
export const OPENAI_FRIENDLY_PROMPT_OVERLAY = `## Interaction Style
@@ -96,7 +96,7 @@ export function shouldApplyOpenAIPromptOverlay(params: {
return false;
}
const normalizedModelId = normalizeLowercaseStringOrEmpty(params.modelId);
return normalizedModelId.startsWith(OPENAI_GPT5_MODEL_PREFIX);
return OPENAI_GPT5_MODEL_ID_PATTERN.test(normalizedModelId);
}
export function resolveOpenAISystemPromptContribution(params: {