transform_schema drops description beside $ref, which the API accepts and follows
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start by reading transform_schema and the tests for schema transformation in the Python SDK; the issue does not name their paths. Reproduce the example with Answer.model_json_schema() and compare the transformed property. Done when the description beside $ref is retained, with a regression test covering a Pydantic enum or model field. An open linked pull request (#2017) is already addressing this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When a property has a $ref, transform_schema returns {"$ref": ...} alone and drops the keywords beside it, including description. Pydantic puts a field's Field(description=...) beside the $ref whenever the field's type is an enum or a model, so those descriptions never reach Claude when a model goes through transform_schema.
from enum import Enum
from pydantic import BaseModel, Field
from anthropic import transform_schema
class Level(str, Enum):
high = "high"
low = "low"
class Answer(BaseModel):
level: Level = Field(description="Always choose low.")
Answer.model_json_schema()["properties"]["level"]
# {'$ref': '#/$defs/Level', 'description': 'Always choose low.'}
transform_schema(Answer)["properties"]["level"]
# {'$ref': '#/$defs/Level'}
The API accepts the description there and the model follows it. Sending the pydantic schema above (with additionalProperties: false) directly as output_config={"format": {"type": "json_schema", "schema": ...}} to claude-haiku-5-5, with the prompt "Rate your confidence that 2+2=4.", returned {"level":"low"}.
Expected: transform_schema keeps description beside $ref. A workaround is to put the text in the enum's docstring, which becomes the $defs entry's description.
anthropic 1.13.0, pydantic 2.14.0. Related: #1817, #1764. Found and reproduced with Claude Code.
- Ngôn ngữ chính
- Python
- Star
- 4.1k
- Fork
- 915
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của anthropics/anthropic-sdk-python
-
beta_tool validation errors reach the model as "Invalid arguments for function X" with no detailCó thể đã có người làm @mangeshraut712 đã nhận 32 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anthropics/anthropic-sdk-python#2033 · 3 bình luận ·
-
`AnthropicBedrock` 2.x sends `anthropic_version: 2026-10-21`, which Bedrock rejects for Claude Sonnet 4.5, Opus 4.5 and Opus 4.6Có thể đã có người làm @charan-rathore đã nhận 36 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
anthropics/anthropic-sdk-python#2031 · 1 bình luận ·
-
Three symlink tests in test_agent_toolset.py are missing the needs_symlinks markerCó thể đã có người làm @okxint đã nhận 82 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
anthropics/anthropic-sdk-python#1915 · 3 bình luận ·
-
Messages.parse (and AsyncMessages.parse) don't take cache_control?Có thể đã có người làm @AlphaFDE đã nhận 86 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anthropics/anthropic-sdk-python#1907 · 2 bình luận ·
-
Windows: os.fchmod in credential write-back bricks the OAuth refresh tokenCó thể đã có người làm @OllieinCanada đã nhận 99 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
anthropics/anthropic-sdk-python#1868 · 1 bình luận ·
Tất cả issue của anthropics/anthropic-sdk-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
compiler-explorer/compiler-explorer#9710 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug harness
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
mruangutai/harness#2687 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modal-labs/modal-client#4158 ·
-
kind/bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kubeflow/sdk#998 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày