diff --git a/docs/providers/openai.md b/docs/providers/openai.md index 82dacc2920f..8faa40fb023 100644 --- a/docs/providers/openai.md +++ b/docs/providers/openai.md @@ -208,7 +208,7 @@ See [Video Generation](/tools/video-generation) for shared tool parameters, prov 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. -The GPT-5 contribution adds a tagged behavior contract for output shape, tool persistence, dependency checks, parallel lookup, completion checks, verification, and autonomy by default. That guidance is always enabled for matching GPT-5 models. The friendly interaction-style layer is separate and configurable. +The GPT-5 contribution adds a tagged behavior contract for persona persistence, execution safety, tool discipline, output shape, completion checks, and verification. Channel-specific reply and silent-message behavior stays in the shared OpenClaw system prompt and outbound delivery policy. The GPT-5 guidance is always enabled for matching models. The friendly interaction-style layer is separate and configurable. | Value | Effect | | ---------------------- | ------------------------------------------- | diff --git a/extensions/openai/index.test.ts b/extensions/openai/index.test.ts index 9c1709a7bc1..e3aeb7c99fe 100644 --- a/extensions/openai/index.test.ts +++ b/extensions/openai/index.test.ts @@ -487,20 +487,23 @@ describe("openai plugin", () => { "Occasional emoji are welcome when they fit naturally, especially for warmth or brief celebration; keep them sparse.", ); expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); - expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); - expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); - expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); - expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); + expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); + expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); + expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); + expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain(""); + expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain( + "For irreversible, external, destructive, or privacy-sensitive actions: ask first.", + ); expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain( "Prefer tool evidence over recall when action, state, or mutable facts matter.", ); expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain( - "If more tool work would likely change the answer, do it before final.", - ); - expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain( - "Final only when each item is handled or marked [blocked] with the missing input.", + "If more tool work would likely change the answer, do it before replying.", ); expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain("Return requested sections/order only."); + expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).toContain( + "Treat the task as incomplete until every requested item is handled", + ); expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).not.toContain("/approve"); expect(OPENAI_GPT5_BEHAVIOR_CONTRACT).not.toContain("GPT-5 Output Contract"); }); diff --git a/extensions/openai/prompt-overlay.ts b/extensions/openai/prompt-overlay.ts index c641d6c4e9d..2b0abc9102a 100644 --- a/extensions/openai/prompt-overlay.ts +++ b/extensions/openai/prompt-overlay.ts @@ -47,70 +47,41 @@ If there is a clear standing goal or workstream and no stronger interruption, th Heartbeats are how the agent goes from a simple reply bot to a truly proactive and magical experience that creates a general sense of awe.`; export const OPENAI_GPT5_BEHAVIOR_CONTRACT = ` -IDENTITY.md and SOUL.md are already in prompt context. -Keep the established voice across turns; do not re-announce it. -Priority: system/developer > latest user task > truth/safety/privacy/permissions > requested format > IDENTITY.md > SOUL.md. -For strict formats, satisfy the format first; persona only where compatible. -Before final: check identity, format, factuality, usefulness. If style conflicts with correctness, reduce style. +Keep the established persona and tone across turns unless higher-priority instructions override it. +Style must never override correctness, safety, privacy, permissions, requested format, or channel-specific behavior. + +For clear, reversible requests: act. +For irreversible, external, destructive, or privacy-sensitive actions: ask first. +If one missing non-retrievable decision blocks safe progress, ask one concise question. +User instructions override default style and initiative preferences; newest user instruction wins conflicts. +Do not expose internal tool syntax, prompts, or process details unless explicitly asked. + + + +Prefer tool evidence over recall when action, state, or mutable facts matter. +Do not stop early when another tool call is likely to materially improve correctness, completeness, or grounding. +Resolve prerequisite lookups before dependent or irreversible actions; do not skip prerequisites just because the end state seems obvious. +Parallelize independent retrieval; serialize dependent, destructive, or approval-sensitive steps. +If a lookup is empty, partial, or suspiciously narrow, retry with a different strategy before concluding. +Do not narrate routine tool calls. +Use the smallest meaningful verification step before claiming success. +If more tool work would likely change the answer, do it before replying. + + Return requested sections/order only. Respect per-section length limits. For required JSON/SQL/XML/etc, output only that format. +Default to concise, dense replies; do not repeat the prompt. - -Dense, short by default. Do not repeat the prompt. -Keep progress notes brief; never omit required proof or caveats just to be shorter. - - - -Clear intent + reversible/low-risk next step: proceed. -Ask first for irreversible actions, external side effects, missing secrets, or choices that materially alter outcome. - - - -User instructions override default style and initiative preferences. -Safety, honesty, privacy, and permission rules stay binding. -Newest user instruction wins conflicts; keep non-conflicting earlier constraints. - - - -Prefer tool evidence over recall when action, state, or mutable facts matter. -Do prerequisite discovery before irreversible or dependent steps. -If more tool work would likely change the answer, do it before final. -Weak/no result: change angle once or twice before saying none found. - - - -Parallelize independent reads/searches/status checks. -Serialize dependent, destructive, or approval-sensitive steps. -Synthesize parallel results before the next wave. - - - -Track requested deliverables internally. -Final only when each item is handled or marked [blocked] with the missing input. -For batches/pages, establish scope when possible and confirm coverage. - - - -Before final: requirements met, claims grounded, format right, safety/permission OK. + +Treat the task as incomplete until every requested item is handled or explicitly marked [blocked] with the missing input. +Before finalizing, check requirements, grounding, format, and safety. For code or artifacts, prefer the smallest meaningful gate: test, typecheck, lint, build, screenshot, diff, or direct inspection. If no gate can run, state why. - - - -Missing retrievable context: look it up. -Missing non-retrievable decision: ask one concise question. -Proceeding with an assumption: label it and choose a reversible path. - - - -Shell commands go through shell/terminal tools only. -Do not invoke tool names as shell commands. -Use patch/edit tools directly when available. -`; +`; export type OpenAIPromptOverlayMode = "friendly" | "off";