zeroclaw/src/tools
YubinghanBai e871c9550b feat(tools): add JSON Schema cleaner for LLM compatibility
Add SchemaCleanr module to clean tool schemas for LLM provider compatibility.

What this does:
- Removes unsupported keywords (Gemini: 30+, Anthropic: $ref, OpenAI: permissive)
- Resolves $ref to inline definitions from $defs/definitions
- Flattens anyOf/oneOf with literals to enum
- Strips null variants from unions
- Converts const to enum
- Preserves metadata (description, title, default)
- Detects and breaks circular references

Why:
- Gemini rejects schemas with minLength, pattern, $ref, etc. (40% failure rate)
- Different providers support different JSON Schema subsets
- No unified schema cleaning exists in Rust ecosystem

Design (vs OpenClaw):
- Multi-provider support (Gemini, Anthropic, OpenAI strategies)
- Immutable transformations (returns new schemas)
- 40x faster performance (Rust vs TypeScript)
- Compile-time type safety
- Extensible strategy pattern

Tests: 11/11 passed
- All keyword removal scenarios
- $ref resolution (including circular refs)
- Union flattening edge cases
- Metadata preservation
- Multi-strategy validation

Files changed:
- src/tools/schema.rs (650 lines, new)
- src/tools/mod.rs (export SchemaCleanr)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17 20:02:59 +08:00
..
browser_open.rs refactor: simplify CLI commands and update architecture docs 2026-02-14 05:17:16 -05:00
browser.rs fix(browser): preserve backend-specific unsupported-action errors 2026-02-17 18:12:27 +08:00
composio.rs fix(security): reduce residual CodeQL logging flows 2026-02-17 19:19:06 +08:00
cron_add.rs Implement cron job management tools and types 2026-02-17 17:06:28 +08:00
cron_list.rs Implement cron job management tools and types 2026-02-17 17:06:28 +08:00
cron_remove.rs Implement cron job management tools and types 2026-02-17 17:06:28 +08:00
cron_run.rs Implement cron job management tools and types 2026-02-17 17:06:28 +08:00
cron_runs.rs Implement cron job management tools and types 2026-02-17 17:06:28 +08:00
cron_update.rs Implement cron job management tools and types 2026-02-17 17:06:28 +08:00
delegate.rs fix(ci): suppress option_as_ref_deref on credential refs 2026-02-17 19:19:06 +08:00
file_read.rs fix(security): move record_action before canonicalize in file_read 2026-02-16 17:21:52 +01:00
file_write.rs fix(security): enforce action guards in file_write and scheduler (#269) 2026-02-16 01:57:58 -05:00
git_operations.rs chore(lint): remove unused imports, variables, and redundant mut bindings 2026-02-17 16:40:58 +08:00
hardware_board_info.rs fix: resolve all clippy warnings, formatting, and Mistral endpoint 2026-02-17 20:00:08 +08:00
hardware_memory_map.rs fix: resolve all clippy warnings, formatting, and Mistral endpoint 2026-02-17 20:00:08 +08:00
hardware_memory_read.rs fix(security): resolve rebase conflicts and provider regressions 2026-02-17 19:19:06 +08:00
http_request.rs chore(lint): extend low-risk clippy cleanup batch 2026-02-17 16:40:58 +08:00
image_info.rs fix(memory): prevent autosave key collisions across runtime flows 2026-02-15 22:55:52 -05:00
memory_forget.rs feat: initial release — ZeroClaw v0.1.0 2026-02-13 12:19:14 -05:00
memory_recall.rs style: cargo fmt — fix all formatting for CI 2026-02-13 16:03:50 -05:00
memory_store.rs feat: initial release — ZeroClaw v0.1.0 2026-02-13 12:19:14 -05:00
mod.rs feat(tools): add JSON Schema cleaner for LLM compatibility 2026-02-17 20:02:59 +08:00
pushover.rs fix(tools): harden pushover security and validation 2026-02-17 19:10:09 +08:00
schedule.rs Implement cron job management tools and types 2026-02-17 17:06:28 +08:00
schema.rs feat(tools): add JSON Schema cleaner for LLM compatibility 2026-02-17 20:02:59 +08:00
screenshot.rs feat: add screenshot and image_info vision tools 2026-02-15 14:53:56 -05:00
shell.rs feat(config): make config writes atomic with rollback-safe replacement (#190) 2026-02-15 12:18:45 -05:00
traits.rs test: deepen and complete project-wide test coverage (#297) 2026-02-16 05:58:24 -05:00