Address automated review comments: span error for ToolExecutionException, README prereqs, and AsyncClient lifecycle

Co-authored-by: TaoChenOSU <12570346+TaoChenOSU@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-16 21:38:01 +00:00
Unverified
parent d3191ffd48
commit 1306e5bce9
3 changed files with 14 additions and 11 deletions
+6 -1
View File
@@ -950,6 +950,7 @@ class MCPTool:
with get_mcp_call_span(span_attributes) as span:
# Try the operation, reconnecting once if the connection is closed
_span_error_set = False
for attempt in range(2):
try:
# Capture the JSON-RPC request ID before the call is made.
@@ -975,9 +976,13 @@ class MCPTool:
error_msg = text or str(parsed)
span.set_attribute(OtelAttr.ERROR_TYPE, "ToolError")
span.set_status(trace.StatusCode.ERROR, error_msg)
_span_error_set = True
raise ToolExecutionException(error_msg)
return parser(result)
except ToolExecutionException:
except ToolExecutionException as ex:
if not _span_error_set:
span.set_attribute(OtelAttr.ERROR_TYPE, type(ex).__name__)
span.set_status(trace.StatusCode.ERROR, str(ex))
raise
except ClosedResourceError as cl_ex:
if attempt == 0: