Skip to content

[codex] Add prompt overlay runtime contracts - #71044

Closed
100yenadmin wants to merge 3 commits into
openclaw:mainfrom
electricsheephq:contract-first/prompt-overlay-runtime-contracts
Closed

100yenadmin wants to merge 3 commits into
openclaw:mainfrom
electricsheephq:contract-first/prompt-overlay-runtime-contracts

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the prompt-overlay contract rung from RFC #71004. This is test-only: no production prompt, provider runtime, Pi runner, or Codex app-server behavior changes.

flowchart TD
  ModelRef["Resolved provider/model"] --> OverlayContract["OpenClaw GPT-5 prompt overlay contract"]
  OverlayContract --> SharedConfig["agents.defaults.promptOverlays.gpt5"]
  OverlayContract --> OpenAIPlugin["OpenAI-family plugin personality fallback"]
  OverlayContract --> CoreResolver["Core GPT-5 overlay resolver"]
  OverlayContract --> CodexProvider["Codex provider contribution surface"]
  CoreResolver --> PromptBundle["Behavior contract + optional interaction style"]
  CodexProvider --> PromptBundle
Loading

Files Changed And Why

File Purpose
test/helpers/agents/prompt-overlay-runtime-contract.ts Shared config/model fixtures for GPT-5 overlay decisions.
src/agents/prompt-overlay-runtime-contract.test.ts Core resolver provider-scope rows.
extensions/codex/prompt-overlay-runtime-contract.test.ts Codex provider contribution surface rows.

Contract Matrix

Surface Contract rows
Core GPT-5 overlay resolver OpenAI-family GPT-5 models get the behavior contract and friendly interaction style by default.
Core GPT-5 overlay resolver Shared agents.defaults.promptOverlays.gpt5.personality = off disables friendly style but preserves behavior contract.
Core GPT-5 overlay resolver plugins.entries.openai.config.personality fallback affects OpenAI-family GPT-5 providers but does not leak to non-OpenAI GPT-5 providers.
Core GPT-5 overlay resolver Codex virtual providers are explicitly in the OpenAI-family personality fallback scope.
Core GPT-5 overlay resolver Non-GPT-5 models do not receive GPT-5 overlays.
Codex provider contribution surface Codex GPT-5 provider runs consume the shared GPT-5 behavior contract.
Codex provider contribution surface Codex respects shared GPT-5 overlay config.
Codex provider contribution surface Non-GPT-5 Codex provider runs do not receive GPT-5 overlays.

How This Helps The RuntimePlan Work

Prompt overlays are OpenClaw-owned policy. The plan should compute overlay chains once and hand them to whichever adapter runs the model. These tests prevent OpenAI plugin personality fallback from leaking into unrelated providers while keeping Codex/OpenAI-family behavior aligned.

Reviewer Notes

  • Test-only; no prompt text changes.
  • Exercises the shared resolver and Codex provider contribution surface, not full Pi prompt-bundle assembly.
  • Captures the audit’s Bug 7 provider-scope class.

Verification

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.agents.config.ts src/agents/prompt-overlay-runtime-contract.test.ts
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extensions.config.ts extensions/codex/prompt-overlay-runtime-contract.test.ts
  • ./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json test/helpers/agents/prompt-overlay-runtime-contract.ts src/agents/prompt-overlay-runtime-contract.test.ts extensions/codex/prompt-overlay-runtime-contract.test.ts
  • git diff --check -- test/helpers/agents/prompt-overlay-runtime-contract.ts src/agents/prompt-overlay-runtime-contract.test.ts extensions/codex/prompt-overlay-runtime-contract.test.ts

Refs #71004
Follows #71009, #71029, #71038, #71039, #71042

@100yenadmin
100yenadmin marked this pull request as ready for review April 24, 2026 09:25
Copilot AI review requested due to automatic review settings April 24, 2026 09:25
@greptile-apps

greptile-apps Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds three test-only files locking the Phase 1 prompt-overlay runtime contracts for GPT-5 overlays on the core agent surface and the Codex provider extension. The src/agents and test/helpers files are correct, but one Codex contract test passes vacuously.

  • The \"keeps OpenAI plugin personality fallback available to Codex GPT-5 provider runs\" test injects provider: CODEX_CONTRACT_PROVIDER_ID via an as never cast, but provider.ts only destructures { config, modelId } from the callback context — the provider ID is never forwarded to resolveCodexSystemPromptContribution. Because providerId arrives as undefined, canUseOpenAiPluginFallback = !undefined = true unconditionally, so the test would still pass even if \"codex\" were removed from OPENAI_FAMILY_GPT5_PROMPT_OVERLAY_PROVIDERS. The contract it claims to lock is not actually enforced.

Confidence Score: 4/5

Safe to merge for test infrastructure, but one Codex contract test has a silent gap that will fail to catch a future regression in provider scoping.

Three of four Codex tests and all core agent tests are correct. One contract test passes vacuously because provider.ts drops the provider ID before reaching the scoping logic, making the OpenAI-family fallback membership check untested. This is a P1 gap in test fidelity — it won't cause a production defect today, but it undermines the stated regression-lock intent of the PR.

extensions/codex/prompt-overlay-runtime-contract.test.ts (lines 39–49) and extensions/codex/provider.ts (lines 93–94) where providerId is not forwarded.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/codex/prompt-overlay-runtime-contract.test.ts
Line: 39-49

Comment:
**Contract test passes vacuously — provider scoping not actually verified**

`provider.ts` line 93–94 destructures only `{ config, modelId }` from the `resolveSystemPromptContribution` context and never forwards `provider` as `providerId` to `resolveCodexSystemPromptContribution`. So when this callback runs, `resolveGpt5PromptOverlayMode` is called with `params.providerId = undefined`, making `canUseOpenAiPluginFallback = !undefined = true` unconditionally.

The `provider: CODEX_CONTRACT_PROVIDER_ID` value injected via the `as never` cast is silently dropped before it ever reaches the scoping logic. The test confirms the OpenAI plugin fallback is available to Codex, but for the wrong reason: it would pass equally if `"codex"` were removed from `OPENAI_FAMILY_GPT5_PROMPT_OVERLAY_PROVIDERS`, because the `!providerId` short-circuit fires first. The regression the contract is supposed to lock cannot be caught by this test as written.

To make the contract meaningful, `provider.ts` should pass the provider ID explicitly — `resolveCodexSystemPromptContribution({ config, modelId, providerId: provider })` — so the set-membership check is actually exercised.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "test: add prompt overlay runtime contrac..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77169629c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Phase 1 “prompt overlay runtime contract” coverage for RFC #71004 by introducing shared fixtures and contract tests that lock current GPT‑5 overlay behavior across core and the Codex provider surface (test-only; no production runtime changes).

Changes:

  • Added a shared test helper to generate minimal config shapes for GPT‑5 overlay scenarios.
  • Added core contract tests for resolveGpt5SystemPromptContribution (behavior contract + friendly style defaults, config overrides, provider scoping, non‑GPT‑5 exclusion).
  • Added Codex provider contract tests to ensure Codex GPT‑5 runs consume the shared overlay behavior and respect shared/plugin config.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
test/helpers/agents/prompt-overlay-runtime-contract.ts Shared constants + config builders used by both core and Codex contract tests.
src/agents/prompt-overlay-runtime-contract.test.ts Core GPT‑5 overlay contract tests for default/override/scoping behavior.
extensions/codex/prompt-overlay-runtime-contract.test.ts Codex provider-side contract tests for GPT‑5 overlay contribution behavior.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Phase 1 “prompt overlay” runtime contract tests to lock current GPT‑5 overlay scoping and configuration behavior across the shared resolver and the Codex provider surface, without changing production runtime behavior.

Changes:

  • Added a shared test helper fixture for GPT‑5 prompt-overlay contract inputs (provider/model ids + config constructors + Codex context builder).
  • Added core contract tests for resolveGpt5SystemPromptContribution() covering default behavior, shared config override, OpenAI plugin fallback scoping, and non‑GPT‑5 behavior.
  • Added Codex extension contract tests asserting Codex provider runs consume the shared GPT‑5 overlay behavior and respect shared config.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test/helpers/agents/prompt-overlay-runtime-contract.ts Shared contract constants + config builders + Codex ProviderSystemPromptContributionContext builder used by tests.
src/agents/prompt-overlay-runtime-contract.test.ts Contract tests for core GPT‑5 overlay resolver behavior/scoping.
extensions/codex/prompt-overlay-runtime-contract.test.ts Contract tests verifying Codex provider integrates the shared GPT‑5 overlay behavior and respects config.

@100yenadmin

Copy link
Copy Markdown
Contributor Author

@steipete gpt 5.4 fixes contract layer

@steipete

Copy link
Copy Markdown
Contributor

Closing as superseded by #71096, which consolidates this contract shard into the single RuntimePlan / Pi-Codex parity review branch.

Codex review note: keeping the individual shard open would split the same contract surface across multiple stale branches now that #71096 carries the combined stack.

@steipete steipete closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants