fix: exclude link-platform channels from available_channels list#564
fix: exclude link-platform channels from available_channels list#564diegohb wants to merge 1 commit intospacedriveapp:mainfrom
Conversation
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.
WalkthroughUpdated the channel filtering logic in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (1)
src/agent/channel.rs
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.