File tree Expand file tree Collapse file tree 2 files changed +3
-1
lines changed
pydantic_ai_slim/pydantic_ai/models Expand file tree Collapse file tree 2 files changed +3
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ]
You can’t perform that action at this time.
0 commit comments