diff --git a/src/strands/agent/agent.py b/src/strands/agent/agent.py index 4579ebacf..52561b1ba 100644 --- a/src/strands/agent/agent.py +++ b/src/strands/agent/agent.py @@ -187,7 +187,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 diff --git a/src/strands/models/sagemaker.py b/src/strands/models/sagemaker.py index d1447732e..4f0bd8427 100644 --- a/src/strands/models/sagemaker.py +++ b/src/strands/models/sagemaker.py @@ -343,7 +343,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 @@ -357,7 +357,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"} @@ -382,7 +382,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"])} ) @@ -402,7 +402,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])} @@ -443,7 +443,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( { @@ -455,7 +455,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"]: @@ -474,9 +474,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, @@ -544,7 +544,7 @@ def format_request_message_content(cls, content: ContentBlock) -> dict[str, 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: