diff --git a/src/strands/models/sagemaker.py b/src/strands/models/sagemaker.py index 7f8b8ff51..1fe630fdc 100644 --- a/src/strands/models/sagemaker.py +++ b/src/strands/models/sagemaker.py @@ -353,7 +353,7 @@ async def stream( logger.info("choice=<%s>", json.dumps(choice, indent=2)) # Handle text content - if choice["delta"].get("content", None): + if choice["delta"].get("content"): if not text_content_started: yield self.format_chunk({"chunk_type": "content_start", "data_type": "text"}) text_content_started = True @@ -367,7 +367,7 @@ async def stream( ) # Handle reasoning content - if choice["delta"].get("reasoning_content", None): + if choice["delta"].get("reasoning_content"): if not reasoning_content_started: yield self.format_chunk( {"chunk_type": "content_start", "data_type": "reasoning_content"} @@ -392,7 +392,7 @@ async def stream( finish_reason = choice["finish_reason"] break - if choice.get("usage", None): + if choice.get("usage"): yield self.format_chunk( {"chunk_type": "metadata", "data": UsageMetadata(**choice["usage"])} ) @@ -412,7 +412,7 @@ async def stream( # Handle tool calling logger.info("tool_calls=<%s>", json.dumps(tool_calls, indent=2)) for tool_deltas in tool_calls.values(): - if not tool_deltas[0]["function"].get("name", None): + if not tool_deltas[0]["function"].get("name"): raise Exception("The model did not provide a tool name.") yield self.format_chunk( {"chunk_type": "content_start", "data_type": "tool", "data": ToolCall(**tool_deltas[0])} @@ -453,7 +453,7 @@ async def stream( yield self.format_chunk({"chunk_type": "content_stop", "data_type": "text"}) # Handle reasoning content - if message.get("reasoning_content", None): + if message.get("reasoning_content"): yield self.format_chunk({"chunk_type": "content_start", "data_type": "reasoning_content"}) yield self.format_chunk( { @@ -465,7 +465,7 @@ async def stream( yield self.format_chunk({"chunk_type": "content_stop", "data_type": "reasoning_content"}) # Handle the tool calling, if any - if message.get("tool_calls", None) or message_stop_reason == "tool_calls": + if message.get("tool_calls") or message_stop_reason == "tool_calls": if not isinstance(message["tool_calls"], list): message["tool_calls"] = [message["tool_calls"]] for tool_call in message["tool_calls"]: @@ -484,9 +484,9 @@ async def stream( # Message close yield self.format_chunk({"chunk_type": "message_stop", "data": message_stop_reason}) # Handle usage metadata - if final_response_json.get("usage", None): + if final_response_json.get("usage"): yield self.format_chunk( - {"chunk_type": "metadata", "data": UsageMetadata(**final_response_json.get("usage", None))} + {"chunk_type": "metadata", "data": UsageMetadata(**final_response_json.get("usage"))} ) except ( self.client.exceptions.InternalFailure, @@ -556,7 +556,7 @@ def format_request_message_content(cls, content: ContentBlock, **kwargs: Any) -> "thinking": content["reasoningContent"].get("reasoningText", {}).get("text", ""), "type": "thinking", } - elif not content.get("reasoningContent", None): + elif not content.get("reasoningContent"): content.pop("reasoningContent", None) if "video" in content: diff --git a/src/strands/tools/_caller.py b/src/strands/tools/_caller.py index 1e0ca2c8d..97485d068 100644 --- a/src/strands/tools/_caller.py +++ b/src/strands/tools/_caller.py @@ -120,7 +120,7 @@ def _find_normalized_tool_name(self, name: str) -> str: """Lookup the tool represented by name, replacing characters with underscores as necessary.""" tool_registry = self._agent.tool_registry.registry - if tool_registry.get(name, None): + if tool_registry.get(name): return name # If the desired name contains underscores, it might be a placeholder for characters that can't be