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:
@@ -209,7 +209,7 @@ class AWSBedrockLLMAdapter(BaseLLMAdapter[AWSBedrockLLMInvocationParams]):
|
|||||||
tool_result_content = [{"json": content_json}]
|
tool_result_content = [{"json": content_json}]
|
||||||
else:
|
else:
|
||||||
tool_result_content = [{"text": message["content"]}]
|
tool_result_content = [{"text": message["content"]}]
|
||||||
except (json.JSONDecodeError, ValueError):
|
except (json.JSONDecodeError, ValueError, AttributeError):
|
||||||
tool_result_content = [{"text": message["content"]}]
|
tool_result_content = [{"text": message["content"]}]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ class AWSBedrockLLMContext(OpenAILLMContext):
|
|||||||
tool_result_content = [{"json": content_json}]
|
tool_result_content = [{"json": content_json}]
|
||||||
else:
|
else:
|
||||||
tool_result_content = [{"text": message["content"]}]
|
tool_result_content = [{"text": message["content"]}]
|
||||||
except (json.JSONDecodeError, ValueError):
|
except (json.JSONDecodeError, ValueError, AttributeError):
|
||||||
tool_result_content = [{"text": message["content"]}]
|
tool_result_content = [{"text": message["content"]}]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -296,10 +296,7 @@ class MCPClient(BaseObject):
|
|||||||
available_tools = await session.list_tools()
|
available_tools = await session.list_tools()
|
||||||
tool_schemas: List[FunctionSchema] = []
|
tool_schemas: List[FunctionSchema] = []
|
||||||
|
|
||||||
try:
|
logger.debug(f"Found {len(available_tools.tools)} available tools")
|
||||||
logger.debug(f"Found {len(available_tools)} available tools")
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
for tool in available_tools.tools:
|
for tool in available_tools.tools:
|
||||||
tool_name = tool.name
|
tool_name = tool.name
|
||||||
|
|||||||
Reference in New Issue
Block a user