anthropics / anthropics/anthropic-sdk-go
Tool input_schema quotes encoding/json.Number bounds as strings
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 213
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 11
Description
## Problem
The Stainless JSON encoder treats `encoding/json.Number` as a string alias. Tool `input_schema` properties that use stdlib `json.Number` for JSON Schema bounds are serialized as quoted strings:
```json
"minimum":"1","maximum":"9007199254740993"
```
Anthropic-compatible endpoints that validate draft 2020-12 reject the whole tool list (`tools.N.custom.input_schema: JSON schema is invalid`).
This shows up when callers store `minimum` / `maximum` / `exclusiveMinimum` / `exclusiveMaximum` as `encoding/json.Number` (to keep integers above 2^53 exact) and put that map on `ToolInputSchemaParam.Properties`.
Reproduced on v1.66.0 with a `bounded_search` tool whose `page_size` argument uses those bounds.
## Expected
The same values should be JSON numbers (`"minimum":1`) so they match JSON Schema and stay exact (not rounded through `float64`).
The encoder already does this for `internal/encoding/json.Number`. Stdlib `encoding/json.Number` is a different named type, so it misses that branch.
## Workaround today
Put `json.RawMessage` (or `param.SetJSON`) on the properties instead of a Go map that still contains `json.Number`.
Contributor guide
Assessment
This issue has not been assessed yet.