Skip to content

perf(command-code): reuse normalized tools for text recovery - #8950

Merged
lidge-jun merged 2 commits into
lidge-jun:devfrom
luvs01:fix/reuse-command-code-wire-schemas
Nov 21, 2026
Merged

lidge-jun merged 2 commits into
lidge-jun:devfrom
luvs01:fix/reuse-command-code-wire-schemas

Conversation

@luvs01

@luvs01 luvs01 commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Reuse each Command Code tool's outbound input schema when preparing its text-call recovery entry. A catalog with two declarations now calls the normalizer twice. Previously it called it four times.
  • Keep the declared schema for recovered argument validation and preserve freeform tool handling. The provider contract describes how the outbound and recovery views are built.

Verification

  • bun test tests/providers/command-code-tool-schema.test.ts tests/providers/command-code-provider.test.ts passed 93 tests. The new regression counts normalizer invocations on two ordinary tool declarations. Existing cases exercise the wire payload, text-call recovery and declared-schema validation.
  • bun run typecheck, bun run structure:check, bun run privacy:scan and git diff --check passed. The local run focused on the affected adapter. The full repository suite was not run locally.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Bug Fixes
    • Improved consistency when preparing tool schemas for requests and processing tool-call recovery. Schema validation continues to use the declared tool schema.
  • Documentation
    • Clarified how schema normalization is handled for Command Code tool declarations and text-call recovery.
  • Tests
    • Added coverage verifying that each tool schema is normalized once and included in the request.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Command Code now prepares tool declarations once per request. It uses normalized schemas for wire declarations and non-freeform recovery, while retaining original declared schemas for validation. A test checks normalization counts, and the provider documentation describes the updated behavior.

Changes: Command Code schema preparation

Layer / File(s) Summary
Prepare and verify tool declarations
src/adapters/command-code.ts, tests/providers/command-code-tool-schema.test.ts, structure/providers-and-adapters.md
prepareTools normalizes each tool’s parameters and returns wire definitions with a declared-tool map. Non-freeform recovery schemas remove $defs and definitions; validation retains the original schema, and freeform tools retain their original schema. Request construction sends the prepared wire definitions and stores the declared-tool map. The test checks that two tools appear in the wire schemas and that normalization runs twice. The documentation describes this behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related PRs

  • lidge-jun/opencodex#8873: It changes Command Code schema normalization, which this PR reuses for text-call recovery.
  • lidge-jun/opencodex#8591: It introduces the Anthropic schema normalizer that this PR uses for tool preparation and recovery.
Merge Risk: Minimal · up to fe6e5

This change avoids redundant tool-schema normalization in Command Code requests and keeps recovery validation and freeform handling intact. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "perf(command-code): reuse normalized tools for text recovery" matches the main change. The adapter now reuses each tool's normalized schema for text-call recovery instead of normalizing aga…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "perf(command-code): reuse normalized tools for text recovery" matches the main change. The adapter now reuses each tool's normalized schema for text-call recovery instead of normalizing again, and the PR objectives report normalizer calls drop from four to two for two declarations. The title is concise and specific. It names the scope (command-code), the change type (perf), and the core idea. The docs and test changes support the same change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1b5f65f and fe6e5d4.

Files selected for processing: 3

  • src/adapters/command-code.ts
  • structure/providers-and-adapters.md
  • tests/providers/command-code-tool-schema.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 19, 2026
@luvs01
luvs01 marked this pull request as ready for review November 20, 2026 04:31
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (MAINTAINERS.md maintainer-integration exception; lane fb2101-queue-b).

  • Exact head: fe6e5d42ea162af58d5fed2ac4105602a28a8b77
  • Checks on this head: all completed checks pass (ci aggregate, gates/test changed where selected, CodeRabbit, enforce-target, hygiene); none pending or failing.
  • Review: terra review APPROVE-WITH-NITS, no correctness defect; command-code tests 93 pass, typecheck exit 0; the new call-count test fails on origin/dev src/adapters/command-code.ts (31 pass / 1 fail) and passes on this head (32 pass).
  • Review threads: 0 unresolved.
  • Scope: perf, no behavior change; no auth, workflow, release, dependency or provider-preset surface.

This is maintainer integration, not an independent approval.

@lidge-jun
lidge-jun merged commit 67a2e5d into lidge-jun:dev Nov 21, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants