chore: tool transforms + typegen#3978
Conversation
ehayes2000
commented
Jun 10, 2026
- cleanup how we do schema transformation and validation on tools
- add transforms to make tools openai compatible
- remove unused schemas from swagger
- remove unneeded anthropic model wrapper
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR refactors AI tool schema generation into two separate paths: ValidatedSchema for provider input validation and FrontendSchemas for TypeScript codegen. It replaces a combined schema approach with a modular, transform-based validation pipeline. The agent code is simplified by removing the AnthropicModel wrapper and using Anthropic's completion model directly. All toolset tests are updated to use the new generate_validated_input_schema API, and OpenAPI definitions are cleaned up to remove obsolete schema types. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rust/cloud-storage/ai_toolset/src/schema/transform/additional_properties.rs (1)
1-41:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftBlocked by repository rule:
ai_toolsetcrate is marked immutable in project guidelines.This change modifies
rust/cloud-storage/ai_toolset/**, which current repository guidance explicitly disallows. Please confirm whether this policy has been superseded for this PR; otherwise this should not merge as-is.As per coding guidelines: “
rust/cloud-storage/ai_toolset/**/*.rs: You are not allowed to ever change this crate”.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/cloud-storage/ai_toolset/src/schema/transform/additional_properties.rs` around lines 1 - 41, The PR changes files in the immutable ai_toolset crate (additional_properties.rs) which violates the repository rule; either revert these edits in AdditionalPropertiesFalse/is_object_schema/transform and restore the original file, or move the new logic into a permitted crate (create a new module with the AdditionalPropertiesFalse transform and is_object_schema helper, then call/import it from the non-immutable crate), or obtain and document an explicit exception from the repo owners before merging—do not merge changes to rust/cloud-storage/ai_toolset/** without that approval.Source: Coding guidelines
🧹 Nitpick comments (1)
rust/cloud-storage/ai_toolset/src/schema/frontend_typegen.rs (1)
138-150: 💤 Low valueTransitive
$refownership search is shallow.
find_owning_toolonly searches the immediate definition of a tool's input/output for the target ref string. If the collided type is referenced indirectly (e.g.,ToolInput -> SharedType -> CollidedType2), the ownership won't be traced through the intermediateSharedTypedefinition.The fallback at line 149 returns the def name itself, so this doesn't break functionality — the renamed type just won't be tool-prefixed in that edge case. This is acceptable for typegen aesthetics but worth noting if naming becomes important later.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/cloud-storage/ai_toolset/src/schema/frontend_typegen.rs` around lines 138 - 150, find_owning_tool currently only checks a tool's immediate input/output definition with Self::value_contains_ref, so transitive $ref chains (e.g., ToolInput -> SharedType -> CollidedType2) are missed; update find_owning_tool to perform a transitive search by walking referenced defs via self.defs (e.g., BFS/DFS) starting from each tool.input and tool.output, invoking value_contains_ref on each visited def and following any $ref targets found in that def, use a visited set to avoid cycles, and return tool.name.clone() as soon as the target ref is discovered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rust/cloud-storage/ai_toolset/src/schema/validate/extract.rs`:
- Around line 1-29: This change touches an immutable crate (the Extract type and
its extract/new methods) which violates the repo rule; either revert the edits
in the Extract implementation and restore the original file, or move the new
functionality into an allowed crate/module: create a new module or crate,
implement the same Extract struct and its methods (new and extract) there,
update references where ValidationError, Extract::new and Extract::extract are
used, and add the new crate/module to Cargo.toml and imports; if you must keep
the change here instead, obtain an explicit exception from the repo owners
before merging.
In `@rust/cloud-storage/ai_toolset/src/toolset/tool_object/mod.rs`:
- Line 12: The change touched an immutable crate (the pub use in mod.rs exposing
SchemaRegistrar and ToolObject) which must not be edited; revert any edits to
rust/cloud-storage/ai_toolset/src/toolset/tool_object/mod.rs and instead
implement your changes outside this crate — for example, create a new crate or
module in an allowed path that depends on the ai_toolset crate and provides the
wrapper, extension trait, or re-export you need (referencing ToolObject and
SchemaRegistrar by name), or move any new logic into the consuming crate rather
than modifying mod.rs.
---
Outside diff comments:
In `@rust/cloud-storage/ai_toolset/src/schema/transform/additional_properties.rs`:
- Around line 1-41: The PR changes files in the immutable ai_toolset crate
(additional_properties.rs) which violates the repository rule; either revert
these edits in AdditionalPropertiesFalse/is_object_schema/transform and restore
the original file, or move the new logic into a permitted crate (create a new
module with the AdditionalPropertiesFalse transform and is_object_schema helper,
then call/import it from the non-immutable crate), or obtain and document an
explicit exception from the repo owners before merging—do not merge changes to
rust/cloud-storage/ai_toolset/** without that approval.
---
Nitpick comments:
In `@rust/cloud-storage/ai_toolset/src/schema/frontend_typegen.rs`:
- Around line 138-150: find_owning_tool currently only checks a tool's immediate
input/output definition with Self::value_contains_ref, so transitive $ref chains
(e.g., ToolInput -> SharedType -> CollidedType2) are missed; update
find_owning_tool to perform a transitive search by walking referenced defs via
self.defs (e.g., BFS/DFS) starting from each tool.input and tool.output,
invoking value_contains_ref on each visited def and following any $ref targets
found in that def, use a visited set to avoid cycles, and return
tool.name.clone() as soon as the target ref is discovered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6b32eb60-0beb-4187-8b81-b6ee19e60ae6
⛔ Files ignored due to path filters (3)
js/app/packages/service-clients/service-cognition/generated/schemas/index.tsis excluded by!**/generated/**js/app/packages/service-clients/service-cognition/generated/schemas/toolSchema.tsis excluded by!**/generated/**js/app/packages/service-clients/service-cognition/generated/schemas/toolSchemas.tsis excluded by!**/generated/**
📒 Files selected for processing (45)
js/app/packages/service-clients/service-cognition/openapi.jsonjs/app/scripts/generate-dcs-tools.tsrust/cloud-storage/agent/src/agent_loop.rsrust/cloud-storage/agent/src/anthropic_model.rsrust/cloud-storage/agent/src/anthropic_model/test.rsrust/cloud-storage/agent/src/completion.rsrust/cloud-storage/agent/src/lib.rsrust/cloud-storage/ai_tools/src/bin/gen_tool_schemas.rsrust/cloud-storage/ai_tools/src/lib.rsrust/cloud-storage/ai_tools/src/search/search_service/content.rsrust/cloud-storage/ai_tools/src/search/search_service/name.rsrust/cloud-storage/ai_toolset/src/schema/error.rsrust/cloud-storage/ai_toolset/src/schema/frontend_typegen.rsrust/cloud-storage/ai_toolset/src/schema/generate.rsrust/cloud-storage/ai_toolset/src/schema/generate/test.rsrust/cloud-storage/ai_toolset/src/schema/mod.rsrust/cloud-storage/ai_toolset/src/schema/phantom_tool.rsrust/cloud-storage/ai_toolset/src/schema/transform/additional_properties.rsrust/cloud-storage/ai_toolset/src/schema/transform/mod.rsrust/cloud-storage/ai_toolset/src/schema/transform/nullify_optional.rsrust/cloud-storage/ai_toolset/src/schema/transform/ref_siblings.rsrust/cloud-storage/ai_toolset/src/schema/transform/required.rsrust/cloud-storage/ai_toolset/src/schema/transform/rewrite_one_of.rsrust/cloud-storage/ai_toolset/src/schema/transform/strip_unsupported.rsrust/cloud-storage/ai_toolset/src/schema/validate/extract.rsrust/cloud-storage/ai_toolset/src/schema/validate/mod.rsrust/cloud-storage/ai_toolset/src/schema/validate/one_of.rsrust/cloud-storage/ai_toolset/src/schema/validate/recursive.rsrust/cloud-storage/ai_toolset/src/schema/validate/recursive/test.rsrust/cloud-storage/ai_toolset/src/schema/validate/strict.rsrust/cloud-storage/ai_toolset/src/toolset/tool_object/mod.rsrust/cloud-storage/ai_toolset/src/toolset/tool_object/object.rsrust/cloud-storage/ai_toolset/src/toolset/tool_object/tool_async.rsrust/cloud-storage/ai_toolset/src/toolset/tool_object/util.rsrust/cloud-storage/ai_toolset/src/toolset/types.rsrust/cloud-storage/call/src/inbound/toolset/test.rsrust/cloud-storage/channels/src/inbound/toolset/test.rsrust/cloud-storage/chat/src/inbound/toolset/test.rsrust/cloud-storage/document_cognition_service/src/api/swagger.rsrust/cloud-storage/documents/src/inbound/toolset/test.rsrust/cloud-storage/email/src/inbound/toolset/test.rsrust/cloud-storage/notification/src/inbound/ai_tool/test.rsrust/cloud-storage/properties/src/inbound/toolset/test.rsrust/cloud-storage/soup/src/inbound/toolset/test.rsrust/cloud-storage/teams/src/inbound/toolset/test.rs
💤 Files with no reviewable changes (7)
- rust/cloud-storage/agent/src/anthropic_model/test.rs
- rust/cloud-storage/ai_toolset/src/toolset/tool_object/object.rs
- rust/cloud-storage/ai_toolset/src/toolset/tool_object/util.rs
- rust/cloud-storage/agent/src/lib.rs
- rust/cloud-storage/document_cognition_service/src/api/swagger.rs
- rust/cloud-storage/agent/src/anthropic_model.rs
- js/app/packages/service-clients/service-cognition/openapi.json