Skip to content

Conversation

@Thuraabtech
Copy link
Contributor

@Thuraabtech Thuraabtech commented Oct 25, 2025

Scope
This PR updates the socket plugin (UDP/TCP) to align with UTCP 1.0 behavior and interface standards. It refines how manual registrations are normalized, adds targeted tests, and ensures consistent behavior with other non-streaming transports.

Key Changes

UTCP Alignment

  • Updated UDPTransport and TCPTransport to match UTCP 1.0 conventions.

  • Implemented register_manual normalization logic to handle legacy tool_provider objects and preserve explicit tool_call_template definitions.

Plugin Registration

  • Added a register() function in utcp_socket/init.py that registers both transports (udp, tcp) and their serializers.

  • Ensured plugin auto-loads via the [project.entry-points."utcp.plugins"] configuration.

Transport Behavior

  • call_tool formats and sends requests over UDP/TCP and decodes responses.

  • call_tool_streaming yields a single chunk to maintain compatibility with other non-streaming transports.

Testing

  • Added comprehensive tests for both UDP and TCP transports:
  • Legacy provider → converted to UDPProvider / TCPProvider.

  • Explicit template → preserved as is.

  • Fallback to manual template when needed.

  • Refactored server setup logic to prevent UnboundLocalError by initializing the server before binding ports.

Script & CI

  • Added scripts/socket_sanity.py for manual verification of transport behavior.

  • Updated CI (.github/workflows/test.yml) to include socket plugin tests during the main test run.

How to Run Locally

pip install -e "core[dev]"
pip install -e plugins/communication_protocols/socket[dev]"
python -m pytest plugins/communication_protocols/socket/tests -v
python scripts/socket_sanity.py


Summary by cubic

Updated the UDP/TCP socket plugin to align with UTCP 1.0 and ensure consistent non-streaming behavior. This addresses the socket-1.0v issue with auto-registration, normalized manual registrations, and full test coverage.

  • New Features

    • Migrated UDP/TCP transports to the CommunicationProtocol interface and UTCP 1.0 conventions.
    • Normalized register_manual: converts legacy tool_provider to tool_call_template and preserves explicit templates (with TCP/UDP serializers).
    • Added utcp.plugins entry point and a register() function to auto-load transports and serializers.
    • call_tool_streaming yields one chunk for parity with other non-streaming transports; added UDP/TCP tests, a socket_sanity.py script, and CI coverage.
  • Bug Fixes

    • Fixed TCP delimiter framing and escaping (uses “\x00” correctly).

Copilot AI review requested due to automatic review settings October 25, 2025 21:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the socket plugin (UDP/TCP) to align with UTCP 1.0 conventions, implementing standardized interfaces and adding comprehensive testing infrastructure.

Key Changes:

  • Migrated from legacy ClientTransportInterface to CommunicationProtocol with updated method signatures (register_manual, call_tool, etc.)
  • Implemented _ensure_tool_call_template normalization logic to handle legacy tool_provider conversion and preserve explicit tool_call_template definitions
  • Added plugin registration infrastructure with auto-loading via entry points and comprehensive test coverage for UDP/TCP transports

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
socket_plugin_test.py Root-level sanity test verifying plugin registration
scripts/socket_sanity.py End-to-end verification script with mock UDP/TCP servers
test_udp_communication_protocol.py Unit tests for UDP transport normalization scenarios
test_tcp_communication_protocol.py Unit tests for TCP transport normalization scenarios
udp_communication_protocol.py Updated UDP transport to UTCP 1.0 interface with normalization logic
udp_call_template.py Added UDPProviderSerializer for legacy provider conversion
tcp_communication_protocol.py Updated TCP transport to UTCP 1.0 interface with normalization logic
tcp_call_template.py Added TCPProviderSerializer and fixed delimiter escape sequences in docstring
__init__.py Plugin registration function for UDP/TCP transports and serializers
pyproject.toml Added entry point for plugin auto-loading
README.md Documentation for running tests and sanity checks
test.yml Updated CI to include socket plugin tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return t

# -------------------------------
# Mock TCP Server (delimiter-based)\n
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

Corrected escape sequence: removed literal '\n' from comment, should be plain text.

Suggested change
# Mock TCP Server (delimiter-based)\n
# Mock TCP Server (delimiter-based)

Copilot uses AI. Check for mistakes.
return []

self._log_info(f"No tools found in TCP provider '{manual_call_template.name}' response")
manual = UtcpManual(tools=tools)
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

Missing required fields in UtcpManual constructor. Based on udp_communication_protocol.py line 274, UtcpManual requires utcp_version and manual_version parameters.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 12 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="scripts/socket_sanity.py">

<violation number="1" location="scripts/socket_sanity.py:212">
Inside the async run_sanity function, time.sleep blocks the event loop; replace it with await asyncio.sleep to keep the coroutine non-blocking.</violation>
</file>

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

# Start servers
start_udp_server(udp_host, udp_port)
start_tcp_server(tcp_host, tcp_port, delimiter="\n")
time.sleep(0.2) # small delay to ensure servers are listening
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 25, 2025

Choose a reason for hiding this comment

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

Inside the async run_sanity function, time.sleep blocks the event loop; replace it with await asyncio.sleep to keep the coroutine non-blocking.

Prompt for AI agents
Address the following comment on scripts/socket_sanity.py at line 212:

<comment>Inside the async run_sanity function, time.sleep blocks the event loop; replace it with await asyncio.sleep to keep the coroutine non-blocking.</comment>

<file context>
@@ -0,0 +1,265 @@
+    # Start servers
+    start_udp_server(udp_host, udp_port)
+    start_tcp_server(tcp_host, tcp_port, delimiter=&quot;\n&quot;)
+    time.sleep(0.2)  # small delay to ensure servers are listening
+
+    # Transports
</file context>
Suggested change
time.sleep(0.2) # small delay to ensure servers are listening
await asyncio.sleep(0.2) # small delay to ensure servers are listening

✅ Addressed in 9cea90f

@Thuraabtech
Copy link
Contributor Author

hi @h3xxit, the test is failing as the mcp_use requires langchain.globals but in the newer langchain API it is named as langchain_core.globals

Comment on lines 19 to 20
"langchain==0.3.27",
"langchain-core==0.3.27"
Copy link
Member

Choose a reason for hiding this comment

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

Probably unintended changes to the MCP package. Please remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw that the tests were failing, so i added the langchain dependencies. Even after adding the dependency, the test is still failing. Now i've removed the mcp_use dependency on langchain.

@h3xxit
Copy link
Member

h3xxit commented Oct 29, 2025

@Thuraabtech Nice! Looks very good. Thank you for the contribution once again!

@h3xxit h3xxit merged commit 4432b15 into universal-tool-calling-protocol:dev Oct 29, 2025
9 checks passed
@Thuraabtech
Copy link
Contributor Author

Loved doing it! Amigo! 😊

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.

2 participants