#17885: fix: replace anyOf union type in image tool schema
agents
stale
size: XS
Cluster:
Tool Schema Fixes and Enhancements
Fixes #17868
## Problem
The `image` tool parameter used `Type.Union([Type.String(), Type.Array(Type.String())])` which generates an `anyOf` in JSON Schema. Claude API rejects `anyOf` in tool schemas.
## Solution
Replace with `Type.String()`. The runtime normalization already handles both string and array inputs gracefully.
## Changes
- `src/agents/tools/image-tool.ts`: Replace `Type.Union([Type.String(), Type.Array(Type.String())])` with `Type.String()`
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Replaced `Type.Union` with `Type.String()` in the `image` tool parameter schema to fix Claude API compatibility (which rejects `anyOf` schemas). The runtime normalization (src/agents/tools/image-tool.ts:387-397) already handles both string and array inputs gracefully, so this change only affects the JSON Schema definition without impacting functionality.
- Aligns with repository style guide (AGENTS.md:179) that prohibits `Type.Union` in tool schemas
- Runtime continues to accept both string and array inputs via existing normalization logic
- Fixes issue #17868
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is minimal (one line), well-documented, and follows repository guidelines. The runtime normalization code ensures backward compatibility with both string and array inputs. The fix addresses a concrete API compatibility issue and aligns with established coding patterns in the repository.
- No files require special attention
<sub>Last reviewed commit: 79feb94</sub>
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
<!-- /greptile_comment -->
Most Similar PRs
#20990: fix: Handle single-element type arrays in tryFlattenLiteralAnyOf
by chilu18 · 2026-02-19
76.5%
#4767: fix(agents): handle read alias required schema
by RomeroYang · 2026-01-30
76.2%
#20249: fix(schema): ensure normalizeToolParameters always includes propert...
by aldoeliacim · 2026-02-18
72.8%
#22214: fix(tools): sanitize google-antigravity schemas for Gemini-compatib...
by Kansodata · 2026-02-20
72.5%
#11141: Fix JSON schema conversion error when using llama.cpp backend
by 9nix00 · 2026-02-07
71.9%
#12642: feat(tools): typed tool schemas for xAI/Grok compatibility
by 2nd-ren · 2026-02-09
71.8%
#23507: fix(tools): strip patternProperties from schemas for OpenAI-compati...
by long-pham · 2026-02-22
70.4%
#21042: fix(ui): render images in tool result messages
by Mellowambience · 2026-02-19
70.0%
#11453: fix: apply normalizeToolName() at all tool lookup points
by sypsyp97 · 2026-02-07
69.9%
#4269: fix: support tool result image format in Control UI
by bobcyw · 2026-01-30
69.5%