Skip to content

[codex] Add schema normalization runtime contracts - #71046

Closed
100yenadmin wants to merge 6 commits into
openclaw:mainfrom
electricsheephq:contract-first/schema-normalization-runtime-contracts
Closed

100yenadmin wants to merge 6 commits into
openclaw:mainfrom
electricsheephq:contract-first/schema-normalization-runtime-contracts

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the schema-normalization contract rung from RFC #71004. This is test-only: no production schema normalization, OpenAI transport, Pi runner, or Codex app-server behavior changes.

flowchart TD
  ToolCatalog["OpenClaw tool catalog"] --> ProviderCompat["Provider schema compatibility hooks"]
  ProviderCompat --> OpenAIResponses["OpenAI HTTP Responses"]
  ProviderCompat --> OpenAIWS["OpenAI WebSocket"]
  ProviderCompat --> ResponsesCompaction["Responses compaction wrapper"]
  ProviderCompat --> CodexDynamicTools["Codex app-server dynamic-tool boundary"]
  OpenAIResponses --> ExecutableSchemas["Executable tool schemas"]
  OpenAIWS --> ExecutableSchemas
  ResponsesCompaction --> ExecutableSchemas
  CodexDynamicTools --> ExecutableSchemas
  ExecutableSchemas --> Todo["TODO: full raw parameter-free strict parity"]
Loading

Files Changed And Why

File Purpose
test/helpers/agents/schema-normalization-runtime-contract.ts Shared schema/model fixtures.
src/plugin-sdk/schema-normalization-runtime-contract.test.ts Provider compatibility hook rows.
src/agents/schema-normalization-runtime-contract.test.ts HTTP Responses, WS, and compaction transport rows.
extensions/codex/src/app-server/schema-normalization-runtime-contract.test.ts Codex dynamic-tool boundary rows.

Contract Matrix

Surface Contract rows
Provider compatibility hooks Native OpenAI Responses parameter-free schemas normalize to strict-compatible object schemas.
Provider compatibility hooks Native OpenAI Codex Responses parameter-free schemas normalize through the same OpenAI-family helper.
Provider compatibility hooks Proxy-like OpenAI routes are not tightened as native OpenAI routes.
Provider compatibility hooks Permissive schemas remain observable for transport-level strict:false downgrade.
HTTP/WS transports HTTP Responses and WebSocket choose matching strict flags for the same mixed strict/permissive tool set.
HTTP/WS transports Provider-prepared parameter-free schemas stay strict-compatible across HTTP Responses and WebSocket.
Responses compaction Provider-prepared executable schemas survive context-management compaction injection unchanged.
HTTP/WS transports Raw parameter-free transport schemas remain executable object shells. Full raw-schema strict-compatible parity is marked todo.
Codex app-server boundary Prepared executable dynamic tool schemas are passed through thread start unchanged. Codex does not own schema normalization in this phase.
Codex app-server boundary Dynamic tool schema changes invalidate the thread fingerprint.

Known Red Row

Future row Why not green here
Raw parameter-free HTTP/WS schemas normalize to the same strict-compatible object shape before transport. Requires moving schema normalization to the shared runtime-plan/tool-catalog boundary.

How This Helps The RuntimePlan Work

Tool schema normalization is OpenClaw-owned policy. The runtime plan should normalize executable schemas once before Pi or Codex transports see them. These tests prevent HTTP Responses, WS, compaction, and Codex dynamic-tool boundaries from drifting during that migration.

Reviewer Notes

  • Test-only; no new schema normalizer API.
  • Does not claim Codex app-server performs schema normalization.
  • Captures the audit’s Bug 6 class and the compaction preservation path.

Verification

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-fast.config.ts src/plugin-sdk/schema-normalization-runtime-contract.test.ts — 4 passed
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-fast.config.ts src/agents/schema-normalization-runtime-contract.test.ts — 4 passed, 1 todo
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extensions.config.ts extensions/codex/src/app-server/schema-normalization-runtime-contract.test.ts
  • ./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json test/helpers/agents/schema-normalization-runtime-contract.ts src/plugin-sdk/schema-normalization-runtime-contract.test.ts src/agents/schema-normalization-runtime-contract.test.ts extensions/codex/src/app-server/schema-normalization-runtime-contract.test.ts
  • git diff --check -- test/helpers/agents/schema-normalization-runtime-contract.ts src/plugin-sdk/schema-normalization-runtime-contract.test.ts src/agents/schema-normalization-runtime-contract.test.ts extensions/codex/src/app-server/schema-normalization-runtime-contract.test.ts

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

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

greptile-apps Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds four test-only files that lock the Phase 1 schema-normalization runtime contracts described in RFC #71004. No production code is changed. The helper module, provider-hooks contracts, HTTP/WS transport alignment contracts, and Codex app-server passthrough/fingerprint contracts are all well-structured and consistent with the production implementations reviewed (normalizeOpenAIToolSchemas, shouldApplyOpenAIToolCompat, startOrResumeThread). The only minor observation is cosmetic: vi.fn() wrappers on the provider-hooks and transport functions are declared at describe-scope without per-test reset and are never checked as spies, making the wrapping a no-op style choice.

Confidence Score: 5/5

Safe to merge — test-only addition with no production code changes.

All four files are new test-only additions. The contract assertions are logically consistent with the production code paths reviewed. The single finding is a P2 style observation about unnecessary vi.fn() wrappers that have no effect on correctness.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/plugin-sdk/schema-normalization-runtime-contract.test.ts
Line: 13-15

Comment:
**`vi.fn()` at describe scope adds no observable value here**

`normalizeToolSchemas` and `inspectToolSchemas` are wrapped with `vi.fn()` at describe-scope and the mocks are never reset between tests, so call-count/call-argument history accumulates across every test in the suite. Since none of the assertions in this file inspect those mocks (only the return values matter), the `vi.fn()` wrapping is a no-op that silently makes the mock history stale after the first test. The same pattern appears in `src/agents/schema-normalization-runtime-contract.test.ts` (lines 13–14). Either assert on the mocks or call the functions directly to keep the intent clear.

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

Reviews (1): Last reviewed commit: "test: add schema normalization runtime c..." | Re-trigger Greptile

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 schema-normalization runtime contract tests (RFC #71004) to lock current executable tool-schema behavior across provider-compat hooks, OpenAI HTTP/WS transports, and the Codex app-server adapter—explicitly test-only with no production behavior changes.

Changes:

  • Introduces shared test fixtures for parameter-free, strict-compatible, and permissive tool schemas plus native/proxy OpenAI(-Codex) model stubs.
  • Adds contract tests in plugin-sdk for OpenAI-family provider tool-schema normalization (native vs proxy behavior).
  • Adds contract tests in agents and extensions/codex to ensure OpenAI HTTP/WS strict-flag alignment, parameter-free normalization, and Codex dynamic-tool schema pass-through + fingerprint invalidation.

Reviewed changes

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

File Description
test/helpers/agents/schema-normalization-runtime-contract.ts Shared fixtures for tool schemas and native/proxy OpenAI(-Codex) model stubs used by contract tests.
src/plugin-sdk/schema-normalization-runtime-contract.test.ts Provider tool-compat contract tests for OpenAI-family schema normalization behavior (native vs proxy, parameter-free normalization).
src/agents/schema-normalization-runtime-contract.test.ts Transport contract tests ensuring HTTP Responses and WebSocket align on strict flags and parameter-free schema normalization.
extensions/codex/src/app-server/schema-normalization-runtime-contract.test.ts Codex adapter contract tests for dynamic tool schema pass-through at thread start and fingerprint invalidation on schema changes.

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

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

@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: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants