Skip to content

feat: adding allowed_communication_protocols field - #26

Merged
Raezil merged 6 commits into
mainfrom
add-allowed_communication_protocols
Dec 2, 2025
Merged

feat: adding allowed_communication_protocols field#26
Raezil merged 6 commits into
mainfrom
add-allowed_communication_protocols

Conversation

@Raezil

@Raezil Raezil commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Summary by cubic

Adds protocol allowlists via allowed_communication_protocols to manuals, call templates, and providers, and enforces them at registration and runtime. Defaults to secure behavior: tools can only use their provider’s own protocol unless explicitly allowed.

  • New Features

    • allowed_communication_protocols added to CallTemplate, ManualV1, and BaseProvider.
    • Provider.allowed_protocols with a secure-by-default fallback to its own protocol.
    • Loader filters out tools using disallowed protocols and propagates manual allowlists to providers.
    • Runtime validation in call_tool and call_tool_stream; tests and README docs included.
  • Migration

    • For cross-protocol tools, set allowed_communication_protocols on your manual or provider (e.g., ["http", "cli"]); an empty array is treated as not set and defaults to the provider’s own protocol.
    • Tools with disallowed protocols are skipped during loading; calls will fail with a clear error.
    • Version bumped to 0.3.0.

Written for commit 8428ffa. Summary will update automatically on new commits.

@Raezil Raezil changed the title feat: add allowed_communication_protocols field feat: adding allowed_communication_protocols field Dec 1, 2025

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

5 issues found across 43 files

Prompt for AI agents (all 5 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="benches/protocol_comparison.rs">

<violation number="1" location="benches/protocol_comparison.rs:57">
P2: Discarding the Result from call_tool hides errors; handle or assert success so benchmark failures are visible.</violation>
</file>

<file name="src/lib.rs">

<violation number="1" location="src/lib.rs:418">
P3: Duplicate validation logic across call_tool and call_tool_stream; consider extracting into a small helper (e.g., validate_allowed_protocol(&amp;ResolvedTool, &amp;str) -&gt; Result&lt;()&gt;).</violation>
</file>

<file name="src/loader.rs">

<violation number="1" location="src/loader.rs:216">
P2: This overwrites any provider-defined allowed_communication_protocols list, removing provider-specific protocol restrictions when a manual-level list is present.</violation>
</file>

<file name="src/providers/base/mod.rs">

<violation number="1" location="src/providers/base/mod.rs:80">
P2: Normalize and validate allowed protocol entries; filter to known keys, lowercase/trim, dedup, and fallback if none valid.</violation>
</file>

<file name="CHANGELOG.md">

<violation number="1" location="CHANGELOG.md:26">
P3: Use updated terminology: replace deprecated &#39;provider_type&#39; with &#39;call_template_type&#39; for consistency.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Comment thread benches/protocol_comparison.rs Outdated
Comment thread src/lib.rs
Comment thread src/loader.rs Outdated
Comment thread src/providers/base/mod.rs
Comment thread CHANGELOG.md Outdated
…ction

- Added validate_allowed_protocol helper to eliminate duplication between call_tool and call_tool_stream
- Reduces code duplication by ~24 lines
- Improves maintainability by centralizing validation logic
- All tests pass (129/129)
@Raezil
Raezil merged commit 026342d into main Dec 2, 2025
4 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