Skip to content

Commit 8172232

Browse files
authored
fix: honor __api_exclude__ in async transform path (#1612)
The sync transform path was updated to pass `exclude=getattr(data, "__api_exclude__", None)` to `model_dump()`, but the async path was missed. This caused `parsed_output` to leak into API requests when using the async client for multi-turn structured output conversations, resulting in a 400 error. Closes #1610
1 parent d7c0974 commit 8172232

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/anthropic/_utils/_transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ async def _async_transform_recursive(
384384
return data
385385

386386
if isinstance(data, pydantic.BaseModel):
387-
return model_dump(data, exclude_unset=True, mode="json")
387+
return model_dump(data, exclude_unset=True, mode="json", exclude=getattr(data, "__api_exclude__", None))
388388

389389
annotated_type = _get_annotated_type(annotation)
390390
if annotated_type is None:

0 commit comments

Comments
 (0)