From ab03d4e0372da700f6ee5aede7e414c020ba6dd1 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 21 Apr 2026 02:28:44 +0100 Subject: [PATCH] fix(openai): default GPT-5 prompt overlay --- docs/providers/openai.md | 16 +++++++++------- extensions/openai/index.test.ts | 19 +++++++++++++++++++ extensions/openai/openclaw.plugin.json | 2 +- extensions/openai/prompt-overlay.ts | 4 ++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/docs/providers/openai.md b/docs/providers/openai.md index dced756c93b..42d7dee119f 100644 --- a/docs/providers/openai.md +++ b/docs/providers/openai.md @@ -206,13 +206,15 @@ See [Video Generation](/tools/video-generation) for shared tool parameters, prov ## Personality overlay -OpenClaw adds a small OpenAI-specific prompt overlay for `openai/*` and `openai-codex/*` runs. The overlay keeps the assistant warm, collaborative, concise, and a little more emotionally expressive without replacing the base system prompt. +OpenClaw adds an OpenAI-specific GPT-5 prompt contribution for `openai/*` and `openai-codex/*` GPT-5-family runs. It lives in the bundled OpenAI plugin, applies to model ids such as `gpt-5`, `gpt-5.2`, `gpt-5.4`, and `gpt-5.4-mini`, and does not apply to older GPT-4.x models. -| Value | Effect | -| ---------------------- | ---------------------------------- | -| `"friendly"` (default) | Enable the OpenAI-specific overlay | -| `"on"` | Alias for `"friendly"` | -| `"off"` | Use base OpenClaw prompt only | +The GPT-5 contribution adds concise output shape, tool-call, and execution-bias guidance by default. The friendly interaction-style layer is configurable. + +| Value | Effect | +| ---------------------- | ------------------------------------------- | +| `"friendly"` (default) | Enable the friendly interaction-style layer | +| `"on"` | Alias for `"friendly"` | +| `"off"` | Disable only the friendly style layer | @@ -234,7 +236,7 @@ OpenClaw adds a small OpenAI-specific prompt overlay for `openai/*` and `openai- -Values are case-insensitive at runtime, so `"Off"` and `"off"` both disable the overlay. +Values are case-insensitive at runtime, so `"Off"` and `"off"` both disable the friendly style layer. ## Voice and speech diff --git a/extensions/openai/index.test.ts b/extensions/openai/index.test.ts index 5c36ddbbee1..18c8755134b 100644 --- a/extensions/openai/index.test.ts +++ b/extensions/openai/index.test.ts @@ -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", () => { diff --git a/extensions/openai/openclaw.plugin.json b/extensions/openai/openclaw.plugin.json index b5e3aed4211..f6fd55ffc15 100644 --- a/extensions/openai/openclaw.plugin.json +++ b/extensions/openai/openclaw.plugin.json @@ -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." } } } diff --git a/extensions/openai/prompt-overlay.ts b/extensions/openai/prompt-overlay.ts index 89ee56f6621..3e857cda7ca 100644 --- a/extensions/openai/prompt-overlay.ts +++ b/extensions/openai/prompt-overlay.ts @@ -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: {