Skip to content

refactor(ai): simplify bounded tool preparation and report broken descriptors - #177997

Merged
steipete merged 4 commits into
mainfrom
deslop/z43-1-tool-schema-20261015
Oct 20, 2026
Merged

steipete merged 4 commits into
mainfrom
deslop/z43-1-tool-schema-20261015

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Simplifies bounded tool preparation and reports broken Anthropic tool descriptors before sending a provider request instead of silently omitting them.

User Impact

Anthropic now returns the original descriptor-access error through its existing stream error path, matching Mistral. Valid tools, prompt ordering, schema validation/detachment, required/pinned tool choices, and public signatures remain unchanged. OpenAI descriptor behavior is unchanged. No migration or configuration change is required.

Why This Change Was Made

The shared 128-level schema boundary makes the private generator trampoline and second cycle tracker redundant. HTTP-date grammar and the retained UTC roundtrip already enforce the removed component checks. Provider request lifecycles already own preparation errors, so descriptor-specific catch-and-drop plumbing adds a silent failure path. Mistral's empty-conversion recovery is unreachable after #173312 stopped filtering conversion failures.

This completes an AI-area residue under the campaign's floor waiver: 107 net production lines removed (+62/-169), excluding tests/docs. It is not counted as a LARGE PR.

Best-effort tradeoffs accepted

Evidence

  • Retained Anthropic descriptor regressions: 6/6 failed on the pre-fix owner for the intended missing-error behavior, then passed with the fix. The pre-fix path reached the safety payload hook instead of reporting the original getter error; the hook prevents network access. Public provider/raw-transport boundaries assert original errors and no payload handoff, including a healthy sibling.
  • Earlier, broader head: 335/335 focused tests passed across 13 files, serial maxWorkers=1, wrapper wall277.77s, including prompt-prefix stability and Mistral's three non-live suites. Unchanged schema/date/Mistral proof is retained; this is prior-head evidence, not a substitute for repaired exact-head CI.
  • Earlier schema/date slice: 70/70 focused tests passed in four files. After a test-fixture type correction, the affected Responses file was rechecked: 62/62 passed, 4.48s Vitest / 9.40s wrapper. The fixture now uses the actual SDK request type, without casts.
  • Targeted production/test typecheck, focused syntax lint, narrow formatting and git diff --check passed. No new suppressions or production import edges; broad graph/platform gates belong to exact-head PR CI under the local CPU limit.
  • The dedicated descriptor sibling now contains only Anthropic's six cases. Previously oversized changed suites shrink; no baseline was changed. Targeted types pass after awaiting the raw transport's possibly promised stream. Suppression ratchet14/14 passed.
  • After dropping the collision-blocked slice, 201/201 focused tests passed across the two formerly failing OpenAI ancillary suites, Anthropic provider/raw transport, six getter regressions and suppression gate (two serial shards30.46s). Targeted types, focused lint, formatting and diff checks pass. Fresh P0–P2 review of the narrowed change is scoped-clean.
  • The retained OpenAI pinned-tool and unreadable-inventory contracts were moved to a small dedicated quarantine suite, not removed. 108/108 tests passed across that sibling, Completions, Responses shared and the suppression gate. Targeted types, focused lint and formatting pass after this mechanical layout repair; no baseline or collision-blocked fixture was changed.
  • Fresh isolated review through P2 found one Mistral concern, rejected after verifying toFunctionTools maps and sorts without filtering: successful nonempty input cannot produce an empty set. The finding assumed the pre-fix(mistral): report unreadable tools before requests #173312 quarantine implementation. Named-tool availability checks remain. The earlier production review was scoped-clean; no accepted/actionable finding remains.
  • No live-provider or deployment claim: this changes local preparation failure handling, not a provider wire contract.
  • Repaired exact head 31af7d48303d3bdc4bd64cd5b7c4dde2d183687b: hosted run39366961998 completed SUCCESS, including all eight UI E2E shards, types, lint, architecture and effective CI/security gates. No CI rerun was requested.

CI repair and parked slice

Initial head 1563cd7bd5eca3b4e6628e40cf4335964a20ec0b had three failing leaf jobs in run39365054613. The OpenAI descriptor cut left obsolete getter fixtures in ancillary tests and made a max-lines suppression unnecessary. Their fixture file is touched by recent open #168513 and #130067. To honor the lane's file-collision rule, the entire OpenAI descriptor/test/consumer slice was removed from this PR and preserved on pushed branch deslop/z43-parked-openai-descriptors-20261015 without another PR. It needs the two fixture migrations after those collisions resolve. No production hunk unrelated to that slice was dropped.

The other failure is custodian-onboarding-locale.e2e.test.ts timing out at the mocked-Gateway browser heading wait, identical to independent queue PR #177986. This is tracked separately as an inherited UI failure; no matching-main reproduction or green CI is claimed. Exact-head CI for the repaired branch remains the broad gate.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 20, 2026 03:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T04:00:45.793568Z 31af7d4 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L labels Oct 20, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR simplifies bounded schema traversal and makes OpenAI and Anthropic report broken tool descriptors before sending requests.

Example: A tool named broken throws "parameters exploded" while a healthy lookup tool is also available.

  • Before: Preparation silently omits broken and continues with lookup.
  • After: Preparation reports "parameters exploded" through the stream error path before request handoff.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The direction and production simplification are supported, but definite consumer-suite failures leave the cutover incomplete.
Proof confidence 🦐 gold shrimp (3/6) Maintainer-authored PR outside the ordinary proof gate; supplied evidence exercises provider and raw Anthropic transport boundaries in process with payload hooks, without claiming a shipped CLI or Gateway run.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: A broken descriptor can silently remove a tool from the model's available inventory.
Reason: The maintainer author explicitly selects visible preparation errors and explains the removed safeguards; the patch reuses existing owners without adding configuration or state.

Merge readiness

⛔ Needs changes before merge - 3 items remain

Keep open: the maintainer-approved simplification is useful, but two unmigrated consumer suites cause definite CI failures.

Priority: P2
Reviewed head: 1563cd7bd5eca3b4e6628e40cf4335964a20ec0b

Before merge

  • Migrate the Responses wire-test description fixture (P2) - Removing this catch makes the throwing description getter in packages/ai/src/providers/openai-responses-tools.integration.test.ts:88 fail preparation. All eight provider/transport serialization scenarios still expect successful responses, exact wire tools, and lifecycle ordering, and exact-head CI reports all eight failing. Use a nonthrowing getter and update its expected wire description so these tests continue exercising serialization and lifecycle behavior; retain throwing-getter rejection in the new descriptor-error suite.
  • Migrate the remaining Completions quarantine fixtures (P2) - The direct parameters read now throws for brokenTool, but packages/ai/src/transports/openai-completions-params.test.ts:836–846 still uses that throwing descriptor to test all-schemas-quarantined and empty-tool history markers. CI confirms both failures: one receives "parameters exploded" instead of the quarantine diagnostic, and the other throws before producing a payload. Replace these fixtures with a genuinely invalid projected schema that remains quarantined, preserving both independent contracts.
  • Complete next step - Have the CI owner attribute the remaining lint and onboarding UI failures against the tested base; neither is currently established as PR-caused.

Findings

  • [P2] Migrate the Responses wire-test description fixture — packages/ai/src/providers/openai-tool-projection.ts:109
  • [P2] Migrate the remaining Completions quarantine fixtures — packages/ai/src/providers/openai-tool-projection.ts:87
Agent review details

How this fits together

The AI package converts runtime tool descriptors into provider request payloads; schema cleaners bound and normalize parameters, while existing stream lifecycles report preparation errors.

flowchart TD
  A[Runtime tool descriptors] --> B[Provider projection]
  B --> C[Bounded schema preparation]
  C --> D[Provider request payload]
  D --> E[Provider transport]
  B --> F[Stream error owner]
  C --> F
Loading

Technical review

Best possible solution:

Keep the existing preparation and stream owners, and migrate the remaining consumer fixtures while preserving their valid-wire, quarantine, and history-marker contracts.

Do we have a high-confidence way to reproduce the issue?

Source shows the old silent omission and the new error path; exact-head CI independently demonstrates the missed consumer expectations, without reviewer execution of target code.

Is this the best way to solve the issue?

The simpler implementation uses existing depth and stream-error owners appropriately, but its cutover is incomplete until the two remaining consumer suites reflect the accepted contract.

Full review comments:

  • [P2] Migrate the Responses wire-test description fixture — packages/ai/src/providers/openai-tool-projection.ts:109
    Removing this catch makes the throwing description getter in packages/ai/src/providers/openai-responses-tools.integration.test.ts:88 fail preparation. All eight provider/transport serialization scenarios still expect successful responses, exact wire tools, and lifecycle ordering, and exact-head CI reports all eight failing. Use a nonthrowing getter and update its expected wire description so these tests continue exercising serialization and lifecycle behavior; retain throwing-getter rejection in the new descriptor-error suite.
    Confidence: 1
  • [P2] Migrate the remaining Completions quarantine fixtures — packages/ai/src/providers/openai-tool-projection.ts:87
    The direct parameters read now throws for brokenTool, but packages/ai/src/transports/openai-completions-params.test.ts:836–846 still uses that throwing descriptor to test all-schemas-quarantined and empty-tool history markers. CI confirms both failures: one receives "parameters exploded" instead of the quarantine diagnostic, and the other throws before producing a payload. Replace these fixtures with a genuinely invalid projected schema that remains quarantined, preserving both independent contracts.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 29a7aa0a4025.

Provenance checked

  • Schema trampoline and cycle tracking changes intended behavior with a stated reason (1d7fd50: Prevent cold-stack overflow in public SDK cleaners; later aecb969 added the retained depth and cycle owner.)
  • OpenAI descriptor and description quarantine changes intended behavior with a stated reason (439a9e9: Preserve healthy siblings and reconcile forced choices after unreadable descriptors; this PR explicitly chooses a visible stream error instead.)
  • Anthropic descriptor quarantine changes intended behavior with a stated reason (a028131: Protect direct/custom inventories and healthy siblings; this PR explains why descriptor-access failures should reach the existing lifecycle error owner.)
  • HTTP-date component validation keeps the original intent (2fd0f88: Reject invalid calendar dates and weekday mismatches; fixed-digit grammar and the retained UTC roundtrip still enforce the removed checks.)
  • Mistral zero-survivor recovery keeps the original intent (991471b: Handle inventories emptied by per-tool filtering; c26f117 removed that filtering.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test packages/ai/src/providers/openai-responses-tools.integration.test.ts packages/ai/src/transports/openai-completions-params.test.ts packages/ai/src/providers/tool-descriptor-errors.test.ts --maxWorkers=1
  • pnpm exec oxfmt --check packages/ai/src/providers/openai-responses-tools.integration.test.ts packages/ai/src/transports/openai-completions-params.test.ts
  • git diff --check

What I checked:

PR surface

Source -139, Tests +10, Docs 0. Total -129 across 15 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 7 73 212 -139
Tests 7 127 117 +10
Docs 1 3 3 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 203 332 -129

Labels

Label changes:

  • add P2: Useful preparation-error improvement with a focused, demonstrated consumer-test repair.
  • add merge-risk: 🚨 compatibility: Throwing descriptor getters now stop requests instead of preserving healthy siblings; the maintainer author explicitly accepts this behavior change.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Useful preparation-error improvement with a focused, demonstrated consumer-test repair.
  • merge-risk: 🚨 compatibility: Throwing descriptor getters now stop requests instead of preserving healthy siblings; the maintainer author explicitly accepts this behavior change.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 19, 2026, 11:52 PM ET / October 20, 2026, 03:52 UTC.

@openclaw-barnacle openclaw-barnacle Bot added size: M and removed agents Agent runtime and tooling size: L labels Oct 20, 2026
@steipete
steipete merged commit a8bc87f into main Oct 20, 2026
127 of 131 checks passed
@steipete
steipete deleted the deslop/z43-1-tool-schema-20261015 branch October 20, 2026 04:53
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…criptors (openclaw#177997)

* refactor(ai): rely on bounded schema traversal and date grammar

* refactor(ai): let stream owners report descriptor failures

* test(ai): build descriptor cases with explicit fields

* refactor(ai): retain OpenAI descriptor quarantine pending fixture migration
tideclaw-bot pushed a commit that referenced this pull request Nov 20, 2026
Honor a8bc87f (#177997): unreadable descriptors fail the stream before request handoff, even with a forced healthy sibling. Keep the live healthy-tool proof focused on readable malformed schemas, and verify forced healthy projection separately offline. No transport behavior or quarantine is restored.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit bfb1fdea6b120a3974369092d615f9fdc7e7131e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant