fix: address review feedback on exception handling

- mcp_service.py: remove unnecessary try/except around debug log,
  use len(available_tools.tools) to match actual iteration target
- bedrock_adapter.py, aws/llm.py: add AttributeError to except tuple
  to handle None content (previously caught by bare except)
This commit is contained in:
kigland
2026-03-08 12:28:03 +08:00
parent 848f35f5df
commit 57f0b6d75b
3 changed files with 3 additions and 6 deletions

View File

@@ -209,7 +209,7 @@ class AWSBedrockLLMAdapter(BaseLLMAdapter[AWSBedrockLLMInvocationParams]):
tool_result_content = [{"json": content_json}]
else:
tool_result_content = [{"text": message["content"]}]
except (json.JSONDecodeError, ValueError):
except (json.JSONDecodeError, ValueError, AttributeError):
tool_result_content = [{"text": message["content"]}]
return {

View File

@@ -369,7 +369,7 @@ class AWSBedrockLLMContext(OpenAILLMContext):
tool_result_content = [{"json": content_json}]
else:
tool_result_content = [{"text": message["content"]}]
except (json.JSONDecodeError, ValueError):
except (json.JSONDecodeError, ValueError, AttributeError):
tool_result_content = [{"text": message["content"]}]
return {

View File

@@ -296,10 +296,7 @@ class MCPClient(BaseObject):
available_tools = await session.list_tools()
tool_schemas: List[FunctionSchema] = []
try:
logger.debug(f"Found {len(available_tools)} available tools")
except Exception:
pass
logger.debug(f"Found {len(available_tools.tools)} available tools")
for tool in available_tools.tools:
tool_name = tool.name