Add docs and update http to 1.0.2 by h3xxit · Pull Request #52 · universal-tool-calling-protocol/python-utcp · GitHub
Skip to content

Add docs and update http to 1.0.2#52

Merged
h3xxit merged 4 commits into
mainfrom
dev
Aug 27, 2025
Merged

Add docs and update http to 1.0.2#52
h3xxit merged 4 commits into
mainfrom
dev

Conversation

@h3xxit

@h3xxit h3xxit commented Aug 27, 2025

Copy link
Copy Markdown
Member

Summary by cubic

Fix HTTP response parsing to respect Content-Type and bump utcp-http to 1.0.2. Also simplify SSE by removing active connection tracking and related teardown.

  • Bug Fixes

    • HTTP: Only parse JSON when Content-Type includes application/json; otherwise return response text to avoid JSON decode errors.
  • Refactors

    • SSE: Removed _active_connections and close(); deregister_manual is now a no-op.
    • SSE: No longer stores response/session in call_tool_streaming; the stream consumer manages lifecycle.
    • Tests: Removed close() teardown and deregister cleanup test.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 4 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment thread plugins/communication_protocols/http/src/utcp_http/http_communication_protocol.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON detection misses +json types (e.g., application/problem+json), causing JSON bodies to be returned as text instead of parsed objects.

Prompt for AI agents
Address the following comment on plugins/communication_protocols/http/src/utcp_http/http_communication_protocol.py at line 315:

<comment>JSON detection misses +json types (e.g., application/problem+json), causing JSON bodies to be returned as text instead of parsed objects.</comment>

<file context>
@@ -310,7 +310,11 @@ async def call_tool(self, caller, tool_name: str, tool_args: Dict[str, Any], too
-                    return await response.json()
+                    
+                    content_type = response.headers.get(&#39;Content-Type&#39;, &#39;&#39;)
+                    if &#39;application/json&#39; in content_type:
+                        return await response.json()
+                    return await response.text()
</file context>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required deregistration is unimplemented, leading to potential resource leaks (open ClientSession/response) and noncompliance with the interface expectations.

Prompt for AI agents
Address the following comment on plugins/communication_protocols/http/src/utcp_http/sse_communication_protocol.py at line 151:

<comment>Required deregistration is unimplemented, leading to potential resource leaks (open ClientSession/response) and noncompliance with the interface expectations.</comment>

<file context>
@@ -148,13 +147,9 @@ async def register_manual(self, caller, manual_call_template: CallTemplate) -&gt; R
-            await session.close()
-
+        Deregister an SSE manual.&quot;&quot;&quot;
+        pass
+    
     async def call_tool(self, caller, tool_name: str, tool_args: Dict[str, Any], tool_call_template: CallTemplate) -&gt; Any:
</file context>

…ication_protocol.py

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@h3xxit h3xxit merged commit 018806c into main Aug 27, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant