enh: allow plaintext for external tool servers

This commit is contained in:
Timothy Jaeryang Baek 2025-08-11 17:36:36 +04:00
parent 17cc3b7d72
commit f890fe6901
1 changed files with 14 additions and 2 deletions

View File

@ -626,7 +626,13 @@ async def execute_tool_server(
if response.status >= 400:
text = await response.text()
raise Exception(f"HTTP error {response.status}: {text}")
return await response.json()
try:
response_data = await response.json()
except Exception:
response_data = await response.text()
return response_data
else:
async with request_method(
final_url,
@ -636,7 +642,13 @@ async def execute_tool_server(
if response.status >= 400:
text = await response.text()
raise Exception(f"HTTP error {response.status}: {text}")
return await response.json()
try:
response_data = await response.json()
except Exception:
response_data = await response.text()
return response_data
except Exception as err:
error = str(err)