Skip to content

Commit 1c2c128

Browse files
committed
adding provider check
1 parent b713ad3 commit 1c2c128

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
@@ -7887,6 +7887,7 @@ async def test_anthropic_container_from_message_history(allow_model_requests: No
78877887
ModelRequest(parts=[UserPromptPart(content='hello')]),
78887888
ModelResponse(
78897889
parts=[TextPart(content='world')],
7890+
provider_name='anthropic',
78907891
provider_details={'container_id': 'container_from_history'},
78917892
),
78927893
]
@@ -7910,6 +7911,7 @@ async def test_anthropic_container_setting_false_ignores_history(allow_model_req
79107911
ModelRequest(parts=[UserPromptPart(content='hello')]),
79117912
ModelResponse(
79127913
parts=[TextPart(content='world')],
7914+
provider_name='anthropic',
79137915
provider_details={'container_id': 'container_should_be_ignored'},
79147916
),
79157917
]

0 commit comments

Comments
 (0)