Improve error handling for tool argument parsing

Fixed the bare `except` issue (JSONDecodeError, ValueError, TypeError)
This commit is contained in:
Harry 2026-03-25 23:17:37 +08:00 committed by GitHub
parent 1cf7953d68
commit 0fe59515ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -650,8 +650,8 @@ class LLMClient:
args_str = json.dumps(args, ensure_ascii=False)[:200]
self._logger.info(f"Calling {tool_name} with args: {args_str}")
except:
pass
except (json.JSONDecodeError, ValueError, TypeError) as e:
self._logger.debug(f"Failed to parse tool arguments for {tool_name}: {e}")
if tool_name not in tool_map:
result = ToolResult(
@ -766,4 +766,4 @@ class LLMClient:
role = msg.get("role", "unknown").upper()
content = msg.get("content", "")
formatted += f"[{role}]\n{content}\n\n"
return formatted
return formatted