Skip to content

fix: exclude link-platform channels from available_channels list#564

Open
diegohb wants to merge 1 commit intospacedriveapp:mainfrom
diegohb:contrib/fix-peer-link-routing
Open

fix: exclude link-platform channels from available_channels list#564
diegohb wants to merge 1 commit intospacedriveapp:mainfrom
diegohb:contrib/fix-peer-link-routing

Conversation

@diegohb
Copy link
Copy Markdown

@diegohb diegohb commented Apr 15, 2026

Link channels (platform=link) are internal agent-to-agent audit trails and have no real messaging adapter. Exposing them in the LLM system prompt caused the LLM to attempt send_message_to_another_channel on them, which fails with a platform resolution error.

Inter-agent communication is exclusively via send_agent_message. Both hierarchical and peer link kinds use the same delegation path; this fix makes the LLM surface consistent with that.

Fixes: peer links never carrying messages while hierarchical links work.

Link channels (platform=link) are internal agent-to-agent audit
trails and have no real messaging adapter. Exposing them in the LLM
system prompt caused the LLM to attempt send_message_to_another_channel
on them, which fails with a platform resolution error.

Inter-agent communication is exclusively via send_agent_message.
Both hierarchical and peer link kinds use the same delegation path;
this fix makes the LLM surface consistent with that.

Fixes: peer links never carrying messages while hierarchical links work.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

Walkthrough

Updated the channel filtering logic in Channel::build_available_channels to exclude channels with platform == "link" alongside existing exclusions for the current channel, cron, and webhook platforms. Added a corresponding unit test to verify the filtering behavior.

Changes

Cohort / File(s) Summary
Channel Filtering Logic
src/agent/channel.rs
Added platform exclusion for "link" in build_available_channels. Introduced unit test available_channels_filter_excludes_link_platform to validate that channels with platform: "link" are filtered out along with cron, webhook, and current channel platforms.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • jamiepine
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: excluding link-platform channels from the available_channels list, which is the core modification in the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation for excluding link-platform channels and the bug it fixes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/agent/channel.rs (1)

4305-4313: Test duplicates the filter predicate instead of validating shared logic.

Right now the test re-implements the predicate inline, so future drift between test and production logic may go unnoticed. Consider extracting a small helper and reusing it in both places.

♻️ Suggested refactor
+fn is_channel_visible_in_available_channels(
+    current_channel_id: &str,
+    channel_id: &str,
+    platform: &str,
+) -> bool {
+    channel_id != current_channel_id
+        && platform != "cron"
+        && platform != "webhook"
+        && platform != "link"
+}
+
 async fn build_available_channels(&self) -> Option<String> {
@@
         let entries: Vec<crate::prompts::engine::ChannelEntry> = channels
             .into_iter()
-            .filter(|channel| {
-                channel.id.as_str() != self.id.as_ref()
-                    && channel.platform != "cron"
-                    && channel.platform != "webhook"
-                    && channel.platform != "link"
-            })
+            .filter(|channel| {
+                is_channel_visible_in_available_channels(
+                    self.id.as_ref(),
+                    channel.id.as_str(),
+                    &channel.platform,
+                )
+            })
             .map(|channel| crate::prompts::engine::ChannelEntry {
                 name: channel.display_name.unwrap_or_else(|| channel.id.clone()),
                 platform: channel.platform,
@@
-        let visible: Vec<_> = channels
+        let visible: Vec<_> = channels
             .into_iter()
-            .filter(|ch| {
-                ch.id.as_str() != current_id
-                    && ch.platform != "cron"
-                    && ch.platform != "webhook"
-                    && ch.platform != "link"
-            })
+            .filter(|ch| {
+                is_channel_visible_in_available_channels(
+                    current_id,
+                    ch.id.as_str(),
+                    &ch.platform,
+                )
+            })
             .collect();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/agent/channel.rs` around lines 4305 - 4313, The test duplicates the
channel filtering predicate; extract the predicate into a shared helper (e.g.,
fn is_channel_visible(ch: &Channel, current_id: &str) -> bool) and replace the
inline predicate in build_available_channels and in the failing test to call
that helper instead; ensure the helper checks ch.id != current_id and platform
!= "cron" && platform != "webhook" && platform != "link", make it pub(crate) or
placed in a module accessible to tests, and update imports in the test to call
the helper so both production code and tests share the same logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/agent/channel.rs`:
- Around line 4305-4313: The test duplicates the channel filtering predicate;
extract the predicate into a shared helper (e.g., fn is_channel_visible(ch:
&Channel, current_id: &str) -> bool) and replace the inline predicate in
build_available_channels and in the failing test to call that helper instead;
ensure the helper checks ch.id != current_id and platform != "cron" && platform
!= "webhook" && platform != "link", make it pub(crate) or placed in a module
accessible to tests, and update imports in the test to call the helper so both
production code and tests share the same logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 65ee04be-f024-4ab4-997d-ff73a243edd9

📥 Commits

Reviewing files that changed from the base of the PR and between df4ac10 and 5900b8d.

📒 Files selected for processing (1)
  • src/agent/channel.rs

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