anthropics / anthropics/anthropic-sdk-go

Tool input_schema quotes encoding/json.Number bounds as strings

Đang mở
#420 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
1.2k
Fork
213
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
11

Mô tả

## 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`.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start at the encoder branch that already handles internal/encoding/json.Number and trace serialization of ToolInputSchemaParam.Properties containing stdlib encoding/json.Number. Reproduce the bounded_search case from the issue, then add or run focused coverage to confirm minimum, maximum, exclusiveMinimum, and exclusiveMaximum are emitted as exact JSON numbers and the tool schema is accepted.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go
Lĩnh vực
backend-api-design
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
72/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.