@@ -207,7 +207,7 @@ class AnthropicModelSettings(ModelSettings, total=False):
207207 By default, if previous messages contain a container_id (from a prior response),
208208 it will be reused automatically.
209209
210- Set to `False` to force a fresh container (ignore any container_id from history).
210+ Set to `False` to force a fresh container (ignore any ` container_id` from history).
211211 Set to a dict (e.g. `{'id': 'container_xxx'}`) to explicitly specify a container.
212212 """
213213
@@ -833,7 +833,7 @@ async def _map_message( # noqa: C901
833833 type = 'web_search_tool_result' ,
834834 content = cast (
835835 BetaWebSearchToolResultBlockParamContentParam ,
836- response_part .content , # pyright: ignore[reportUnknownMemberType]
836+ response_part .content ,
837837 ),
838838 )
839839 )
@@ -847,7 +847,7 @@ async def _map_message( # noqa: C901
847847 type = 'code_execution_tool_result' ,
848848 content = cast (
849849 BetaCodeExecutionToolResultBlockParamContentParam ,
850- response_part .content , # pyright: ignore[reportUnknownMemberType]
850+ response_part .content ,
851851 ),
852852 )
853853 )
@@ -860,7 +860,7 @@ async def _map_message( # noqa: C901
860860 type = 'web_fetch_tool_result' ,
861861 content = cast (
862862 WebFetchToolResultBlockParamContent ,
863- response_part .content , # pyright: ignore[reportUnknownMemberType]
863+ response_part .content ,
864864 ),
865865 )
866866 )
@@ -871,7 +871,7 @@ async def _map_message( # noqa: C901
871871 BetaMCPToolResultBlock (
872872 tool_use_id = tool_use_id ,
873873 type = 'mcp_tool_result' ,
874- ** cast (dict [str , Any ], response_part .content ), # pyright: ignore[reportUnknownMemberType]
874+ ** cast (dict [str , Any ], response_part .content ),
875875 )
876876 )
877877 elif isinstance (response_part , FilePart ): # pragma: no cover
@@ -909,12 +909,12 @@ async def _map_message( # noqa: C901
909909 # If anthropic_cache_instructions is enabled, return system prompt as a list with cache_control
910910 if system_prompt and (cache_instructions := model_settings .get ('anthropic_cache_instructions' )):
911911 # If True, use '5m'; otherwise use the specified ttl value
912- ttl : Literal ['5m' , '1h' ] = '5m' if cache_instructions is True else cache_instructions
912+ instructions_ttl : Literal ['5m' , '1h' ] = '5m' if cache_instructions is True else cache_instructions
913913 system_prompt_blocks = [
914914 BetaTextBlockParam (
915915 type = 'text' ,
916916 text = system_prompt ,
917- cache_control = self ._build_cache_control (ttl ),
917+ cache_control = self ._build_cache_control (instructions_ttl ),
918918 )
919919 ]
920920 return system_prompt_blocks , anthropic_messages
@@ -1272,7 +1272,8 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
12721272 elif isinstance (event , BetaRawMessageDeltaEvent ):
12731273 self ._usage = _map_usage (event , self ._provider_name , self ._provider_url , self ._model_name , self ._usage )
12741274 if raw_finish_reason := event .delta .stop_reason : # pragma: no branch
1275- self .provider_details = {** (self .provider_details or {}), 'finish_reason' : raw_finish_reason }
1275+ self .provider_details = self .provider_details or {}
1276+ self .provider_details ['finish_reason' ] = raw_finish_reason
12761277 self .finish_reason = _FINISH_REASON_MAP .get (raw_finish_reason )
12771278
12781279 elif isinstance (event , BetaRawContentBlockStopEvent ): # pragma: no branch
0 commit comments