Skip to content

Commit 1351ede

Browse files
committed
adding provider check
1 parent 1fced1d commit 1351ede

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pydantic_ai_slim/pydantic_ai/models/anthropic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def _get_container(
459459
if (container := model_settings.get('anthropic_container')) is not None:
460460
return None if container is False else container
461461
for m in reversed(messages):
462-
if isinstance(m, ModelResponse) and m.provider_details:
462+
if isinstance(m, ModelResponse) and m.provider_name == self.system and m.provider_details:
463463
if cid := m.provider_details.get('container_id'):
464464
return BetaContainerParams(id=cid)
465465
return None

tests/models/test_anthropic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7930,6 +7930,7 @@ async def test_anthropic_container_from_message_history(allow_model_requests: No
79307930
ModelRequest(parts=[UserPromptPart(content='hello')]),
79317931
ModelResponse(
79327932
parts=[TextPart(content='world')],
7933+
provider_name='anthropic',
79337934
provider_details={'container_id': 'container_from_history'},
79347935
),
79357936
]
@@ -7953,6 +7954,7 @@ async def test_anthropic_container_setting_false_ignores_history(allow_model_req
79537954
ModelRequest(parts=[UserPromptPart(content='hello')]),
79547955
ModelResponse(
79557956
parts=[TextPart(content='world')],
7957+
provider_name='anthropic',
79567958
provider_details={'container_id': 'container_should_be_ignored'},
79577959
),
79587960
]

0 commit comments

Comments
 (0)