feat: support channel routing to dispatch messages to different agents#1889
Closed
ixiadao wants to merge 1 commit intoagentscope-ai:mainfrom
Closed
feat: support channel routing to dispatch messages to different agents#1889ixiadao wants to merge 1 commit intoagentscope-ai:mainfrom
ixiadao wants to merge 1 commit intoagentscope-ai:mainfrom
Conversation
Add channel_routing configuration to route channel messages (e.g. Feishu) to specific agents based on meta fields like chat_id. Changes: - Add ChannelRoutingRule model in config - Add _resolve_channel_routing and _get_routed_process in BaseChannel - Override _run_process_loop in FeishuChannel to support routing - Inject routing rules during app startup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add channel routing support to dispatch channel messages to different agents based on configurable rules. This enables a single channel (e.g. one Feishu bot) to serve multiple agents by routing messages based on meta fields like
feishu_chat_id.Changes
config/config.pyChannelRoutingRulemodel with fields:channel,match_field,match_value,target_agent_idchannel_routingfield toAgentsConfigapp/channels/base.py_channel_routing_rulesand_multi_agent_managertoBaseChannel.__init___resolve_channel_routing()to match meta fields against routing rules_get_routed_process()to get the target agent'sstream_queryhandler_run_process_loop()to use routed process when a rule matchesapp/channels/feishu/channel.py_run_process_loop()to support channel routing (Feishu overrides the base method, so routing must be added here too)app/_app.pymulti_agent_managerinto default agent's channels during startupConfiguration Example
{ "agents": { "channel_routing": [ { "channel": "feishu", "match_field": "feishu_chat_id", "match_value": "oc_xxxx", "target_agent_id": "agent_1" } ] } }Use Case
When running multiple agents, users often want a single Feishu bot (one App) to serve different agents in different group chats. This PR enables that by routing messages based on the group chat ID to the appropriate agent.
Testing