dsh-wechat-agent-router: Route Sessions to Different Agent Presets Based on WeChat Group Names

Preface

In DeepSeek Harness (DSH), the common way to integrate WeChat is by installing dsh-wechat-assistant, which handles group monitoring, message sending/receiving, serial queues, etc. However, when creating group sessions, the bridge code hardcodes agentPreset as wechat. If you want “integration groups to use the IoT-specific Agent and summary groups to use the Archive Agent,” while other groups continue to use the default WeChat assistant preset, modifying the assistant source code or maintaining a fork is costly.

The following introduces dsh-wechat-agent-router (npm package name dsh-wechat-agent-router, repository let-mi-think/wechat-agent-router). It does only one thing: determines which Agent preset to use for a group session based on the WeChat group name. Monitoring, message reading, @ detection, archiving, and sharded replies are still handled entirely by dsh-wechat-assistant; this plugin does not modify a single line of it.

What is this

Maintained by let-mi-think. The plugin runs on the DSH host plane, providing a settings section called “WeChat Routing”. It has no preset plane—it does not enter Agent composition; it only intervenes on the host side regarding the value “which preset this group’s session uses”.

Functionally, it depends on the installed dsh-wechat-assistant: this plugin does not monitor or send/receive messages. If the WeChat assistant is not installed, the plugin can still load, but the group list in the panel will be empty, leaving nothing to route.

Core Features

Routing Rules

  • Group name → Agent preset id: supports contains (default, case-insensitive) and exact matching.
  • Rules are executed top-down; the first match applies.
  • Optional defaultAgent acts as a fallback; an empty string means no intervention, following the wechat preset originally designated by the WeChat assistant.

Zero-Intrusion Implementation

When dsh-wechat-assistant creates a group session, it calls apiProxy.sessions.create and passes agentPreset: 'wechat'. This plugin only wraps sessions.create on the host plane: it reverse-looks-up the group name via sessionId, calculates the target preset, rewrites agentPreset, and then allows the process to continue.

Groups and sessions correspond one-to-one: sessionId = 'wechat-group-' + sha256(group_name).slice(0,32) (consistent with the assistant’s algorithm; literals are locked by regression tests in the repository).

Activation Semantics

  • DSH stipulates that agentPreset.select is only allowed when a session has not run a turn yet; group sessions with existing history will not be modified (the panel displays “Has History”).
  • The plugin does two things: ① Wraps sessions.create so new sessions use the correct preset from the start; ② After startup and every configuration save, scans existing group sessions to correct those with blank === true and incorrect presets.
  • Configuration changes take effect immediately for new sessions without needing to restart DSH.

Configuration Interface

After installation and restarting dsh web, go to Settings → WeChat Routing (parallel to “Agent Management”). You can view the current actual preset, the target calculated by routing, and whether they are consistent for each monitored group.

Installation and Activation

Host requirements: dsh 0.1.0-rc.7 (see dsh.engines.dsh in the package); Node ^22.19.0 || ^24.0.0. The client artifact lib/client.js is distributed with the package, so no build is needed during installation.

Official installation command:

dsh plugin --profile web add dsh-wechat-agent-router

After installation, restart dsh web, and the WeChat Routing section will appear in Settings. Please ensure dsh-wechat-assistant is installed and configured first, otherwise there will be no groups to route.

Configuration is written in the plugin section of ~/.dsh/settings.yaml (it only reads the WeChat assistant’s groups to know the group list and does not modify the assistant section):

wechat-agent-router:
  enabled: true            # Disabled = No intervention at all
  defaultAgent: ''         # Fallback; empty string = No intervention (follow wechat)
  rules:                   # Top-down, first match applies
    - match: 对接           # Group name keyword
      mode: contains       # contains (default) | exact
      agent: iot
    - match: 群聊总结
      mode: exact
      agent: archive-agent

Typical Usage

  1. Install dsh-wechat-assistant and complete WeChat group monitoring configuration.
  2. Install this plugin using the command above and restart dsh web.
  3. Fill in rules in Settings → WeChat Routing, or edit the wechat-agent-router section in settings.yaml.
  4. Prepare corresponding Agent presets (prompts, knowledge bases, MCP, etc.) for different businesses, and fill in the preset id for agent in the rules.
  5. For new groups or blank group sessions that have not been chatted in, the configuration will be corrected according to rules after saving; sessions that already have conversation history in that group will retain their original preset.

Applicable Scenarios and Notes

Suitable for: Multiple WeChat groups requiring different Agent capabilities (dedicated knowledge bases, different MCPs, different system prompts), while wishing to continue using the official WeChat assistant as the transport layer.

Known Limitations (from README):

  • The granularity is “Group = One Session = One Agent”; it cannot switch Agents based on message content within the same group.
  • Direct messages are not supported; the assistant’s Python side only accepts group chat targets.
  • The bridge forces the model selection to the global modelProvider/modelName for every message, overriding the model in the Agent preset; if the model needs to change with routing, additional handling is required.
  • If the upstream changes the sessionId algorithm, routing may fail to match the group and degrade to “no intervention” (no error but ineffective).
  • If wrapping fails, a clear prompt will be given in the logs and at the top of the panel, rather than failing silently.

The plugin runs with the permissions of the current DSH process. Before installation, it is recommended to review the source code and the MIT license on the GitHub repository to ensure it meets your environment and compliance requirements. The DSH community plugin directory is an independent site (e.g., SkillHub entry page) and has no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-wechat-agent-router consolidates “selecting Agent by group” into host-side routing and configuration, reusing the entire message chain of dsh-wechat-assistant. When you need to route presets by group, you can integrate it via the official installation command and maintain rules in settings or YAML.

  • Directory Page: https://www.skillhub.cn/plugins/let-mi-think/wechat-agent-router
  • GitHub: https://github.com/let-mi-think/wechat-agent-router
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye