@@ -92,19 +92,22 @@ async def err_tool(ctx: Ctx, params: CallToolRequestParams) -> CallToolResult:
9292
9393
9494@pytest .mark .anyio
95- async def test_tool_error_snake_case_dict_result_sets_error_type (server : SrvT , spans : SpanCapture ):
95+ async def test_snake_case_dict_result_is_not_a_tool_error (server : SrvT , spans : SpanCapture ):
96+ # `is_error` is alias-only on the wire, so serialization drops it; the result reaches the
97+ # client as a success and the span must not contradict that.
9698 async def err_tool (ctx : Ctx , params : CallToolRequestParams ) -> dict [str , Any ]:
9799 return {"content" : [], "is_error" : True }
98100
99101 server .add_request_handler ("tools/call" , CallToolRequestParams , err_tool )
100102 server .middleware .append (OpenTelemetryMiddleware ())
101103 async with connected_runner (server ) as (client , _ ):
102104 spans .clear ()
103- await client .send_raw_request ("tools/call" , {"name" : "mytool" , "arguments" : {}})
105+ result = await client .send_raw_request ("tools/call" , {"name" : "mytool" , "arguments" : {}})
106+ assert result == {"content" : []}
104107 [span ] = [s for s in spans .finished () if s .kind == SpanKind .SERVER ]
105108 assert span .attributes is not None
106- assert span . attributes [ "error.type" ] == "tool_error"
107- assert span .status .status_code == StatusCode .ERROR
109+ assert "error.type" not in span . attributes
110+ assert span .status .status_code == StatusCode .UNSET
108111
109112
110113@pytest .mark .anyio
0 commit comments