Repository navigation
fix: preserve compact plugin tool argument types for Codex - #157734
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 25, 2026, 5:55 PM ET / 21:55 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch preserves eligible shared definitions in OpenAI-facing plugin tool schemas and teaches host argument validation to coerce values through those references. Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open. Current main still expands the references that this branch preserves, and the latest commit addresses the prior host-coercion finding. The real Codex registration probe confirms a compact schema was accepted, but does not show whether Codex displays the nested argument types whose loss prompted the fix. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw normalizes plugin tool schemas for the selected model before projecting them into Codex dynamic tool declarations or direct OpenAI requests. Model-emitted arguments then pass through host validation before a tool runs. flowchart LR
A[Plugin tool schema] --> B[Provider normalization]
B --> C[Codex tool projection]
C --> D[Codex declaration]
D --> E[Model tool call]
E --> F[Host argument validation]
F --> G[Tool execution]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +161, Tests +425, Other -1. Total +585 across 7 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain compact references for Codex-compatible tool schemas while preserving direct OpenAI inlining and host coercion, then show the resulting nested argument types in Codex output. Do we have a high-confidence way to reproduce the issue? Yes, current-main inlining and Codex's 5,000-byte compaction policy give a high-confidence source-level path using the PR's synthetic schema. I did not execute the untrusted branch in this read-only review. Is this the best way to solve the issue? Yes, the patch changes the existing normalization and validation owners and keeps the documented provider fallbacks. The user-visible Codex declaration outcome still needs direct observation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 800bf8e10e7c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Resolve eligible root definitions during host argument coercion while keeping model-facing schemas compact. Preserve root-aware union validation, recursive data traversal, and TypeBox refinements. Addresses ClawSweeper feedback on #157734. Co-authored-by: jalehman <[email protected]>
…157734) * fix: preserve compact plugin tool argument types for Codex * fix: preserve coercion for referenced tool arguments Resolve eligible root definitions during host argument coercion while keeping model-facing schemas compact. Preserve root-aware union validation, recursive data traversal, and TypeBox refinements. Addresses ClawSweeper feedback on openclaw#157734. Co-authored-by: jalehman <[email protected]> --------- Co-authored-by: roboclaw-bot <[email protected]>
Related: #156957. Related implementation context: #81238, #139431, and #132442.
What Problem This Solves
Fixes complex plugin tool arguments appearing as
unknownin Codex when shared schema definitions are expanded beyond its declaration-compaction budget.User Impact
Agents retain useful nested argument types for compact, reference-bearing plugin tools. The change is in shared OpenAI-provider normalization, not a Knowledge-specific exception. Other providers and unsupported shapes keep the existing expansion path. No configuration or migration is required.
Why This Change Was Made
Expanding a shared definition at each use can turn a small schema into one large enough for Codex to discard nested types. Preserve eligible root
$defs/definitionsreferences for OpenAI-provider normalization, while retaining inlining for unresolved or scoped references, malformed definition tables, root unions, OpenAPI components, nullable reference nodes, and incompatible provider profiles/keywords. References confined to unused definition tables do not activate preservation.The reference helper is extracted from the existing normalizer to keep the fix within the repository line cap; both baseline changes shrink existing exceptions. This PR contains only the host fix, not the Knowledge plugin's ingestion work.
The review follow-up restores host coercion for preserved references without expanding the model-facing schema. Union checks retain root context and TypeBox refinements; recursive data locations remain independent. Unsupported identifier/scoped-definition shapes keep the existing inlining path.
Compatibility detail: bundled MCP materialization still uses provider-neutral inlining. Direct OpenAI Responses payload conversion also still inlines references at its later provider-neutral conversion boundary, with both strict modes verified. This patch does not switch every outgoing OpenAI API request to reference-bearing schemas.
Evidence
Review-feedback correction — 46ce73c
Limits: registration acceptance is not renderer or external OpenAI inference proof; neither was run. Codex's schema-size limits remain. The reproduced regression affects embedded-host coercion, not the separate Codex bridge validator. Hosted PR CI for this commit passed on 2026-09-25: 140 successful jobs, 20 skipped, no failures; openclaw/ci-gate and applicable security/dependency checks succeeded.
Commands, redacted registration result, and correction scope
Redacted actual registration result:
Pinned source inspected directly: schema preparation and compaction.
Correction scope: three files; production +114/−28 (net +86), tests +244. Necessary growth is reference resolution, root-bound validator caching and recursion context in the existing owner. No second projection, dependency change, protocol/schema bump or baseline expansion. The 64-KiB limit, nullable policy, final validation and TypeBox recovery remain intact.
An initial remote check used a stale comparator; final proof uses the pinned PR merge base above. An intermediate overbroad typecheck was cancelled, not counted as passing; all 25 graphs completed in the final check. Both task Testboxes are stopped. The local formatting hook lacked worktree dependencies; its documented recovery was used only after separate formatting proof and matching candidate hashes.
Original pre-feedback verification at the previous PR head
pnpm test packages/ai/src/providers/agent-tools-parameter-schema.test.ts --maxWorkers=1; 2.52 s wall, 891 ms Vitest duration.agent-tools-parameter-schema(19),openai-tool-schema+openai-tool-schema-reuse(30),tool-schema-projection(20), andagent-tools.schema+ bundled MCP materialization (108).convertResponsesToolPayloadentry point verified both strict modes retain nested field types and keep outgoing references inlined.Autoreview: the first independent pass identified two reproduced gate defects (unused definitions and malformed definition tables); both were fixed with regressions demonstrated failing before and passing after. Its strict-reference-sibling concern was checked against the real downstream payload converter: both strict modes inline references, covered by new payload regressions. A second independent review completed on the revised patch and accepted the strict-mode disposition. It reported one P2 concern about unused definitions alongside a live reference. That finding is rejected with downstream evidence: Codex prepares schemas by pruning unreachable definitions before compaction, and its regression explicitly covers a live reference plus an unused definition. The reviewer did not have that downstream source. This is a completed review with a documented rejected finding, not a zero-findings verdict.
Checks: core typecheck and all 25 test-typecheck shards passed; revised files passed fresh core/package typechecking, formatting, and targeted lint.
node scripts/check-changed.mjspassed its checks through the dead-export scans, then failed on the existingeslint(max-lines)violation in unchangedsrc/agents/workspace.test.ts:1215(1,017 counted lines, limit 1,000). Verified that file has no diff; this PR does not alter it. Later checks in that command did not run.Evidence limits: no fresh external OpenAI API request or Rust Codex renderer test is included in this run. The TypeScript regression checks schema structure/projection and size, not the renderer itself. Remaining Codex compaction/render limits still apply to sufficiently large schemas; this is not a general removal of those limits. A concurrent final-suite run hit the worker compiler guard (
Source changed during compiled subprocess invocation: pnpm-lock.yaml); lockfile content is unchanged. After the competing preparation commands ended, direct sequential replay of the affected agents-core files passed all 108 tests. This PR does not claim to fix that harness race. Hosted CI timing is pending.Original implementation by @jalehman; this review follow-up was made at their request.
Work sessions