Skip to content

Commit 0f2af7e

Browse files
authored
Merge pull request #53 from universal-tool-calling-protocol/dev
Fix response json parsing when content type is wrong
2 parents 018806c + 5bd9536 commit 0f2af7e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

plugins/communication_protocols/http/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "utcp-http"
7-
version = "1.0.2"
7+
version = "1.0.3"
88
authors = [
99
{ name = "UTCP Contributors" },
1010
]

plugins/communication_protocols/http/src/utcp_http/http_communication_protocol.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,11 @@ async def call_tool(self, caller, tool_name: str, tool_args: Dict[str, Any], too
313313

314314
content_type = response.headers.get('Content-Type', '').lower()
315315
if 'application/json' in content_type:
316-
return await response.json()
316+
try:
317+
return await response.json()
318+
except Exception:
319+
logger.error(f"Error parsing JSON response from tool '{tool_name}' on call template '{tool_call_template.name}', even though Content-Type was application/json")
320+
return await response.text()
317321
return await response.text()
318322

319323
except aiohttp.ClientResponseError as e:

0 commit comments

Comments
 (0)