Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cloud_engineer_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
aws_diagram_mcp_client = None

# Get tools from MCP clients (if initialized)
docs_tools = aws_docs_mcp_client.list_tools_sync() if mcp_initialized and aws_docs_mcp_client else []
diagram_tools = aws_diagram_mcp_client.list_tools_sync() if mcp_initialized and aws_diagram_mcp_client else []
docs_tools = aws_docs_mcp_client.list_tools_sync() if mcp_initialized else []
diagram_tools = aws_diagram_mcp_client.list_tools_sync() if mcp_initialized else []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: Removing the null checks creates a potential crash risk. If mcp_initialized is True but the MCP clients are None (which could happen if the initialization logic changes in the future), this will cause an AttributeError when calling list_tools_sync() on None. The redundant checks provide defensive programming against future code changes.

Suggested change
docs_tools = aws_docs_mcp_client.list_tools_sync() if mcp_initialized else []
diagram_tools = aws_diagram_mcp_client.list_tools_sync() if mcp_initialized else []
docs_tools = aws_docs_mcp_client.list_tools_sync() if mcp_initialized and aws_docs_mcp_client else []
diagram_tools = aws_diagram_mcp_client.list_tools_sync() if mcp_initialized and aws_diagram_mcp_client else []


# Create a BedrockModel with system inference profile
bedrock_model = BedrockModel(
Expand Down