dsh-egress-router: DSH Egress Traffic Splitting for Direct Model Access and Proxy-based Fetching

Introduction

When building agents in DeepSeek Harness (DSH), model conversations often share the same proxy strategy as web_fetch and subprocess outbound connections. Natively, DSH reads proxy environment variables only once at startup, making it impossible to route by purpose during runtime. If the proxy is disabled, web_fetch can easily fail directly. To change the proxy, you typically have to modify ~/.dsh/.env and restart the application. This article introduces the community plugin dsh-egress-router (maintained by fengyevvv). It mounts outbound policies onto the process-level active policy of @deepseek-ai/dsh-http-proxy, allows switching modes via the Web UI, and supports automatic fallback when the proxy is unavailable.

What is this

dsh-egress-router is an outbound traffic routing plugin for DSH, categorized as a networking tool. In short: DeepSeek model requests prefer direct connections, while external model-related fetching and subprocesses use the HTTP(S) proxy. If the proxy fails, it falls back to direct connection, and switches back upon recovery. The current version is 0.1.1, licensed under MIT; see SkillHub for the directory page and GitHub for the source code.

The plugin does not rely on .env for state, resulting in zero I/O on the startup path; any exception degrades to a direct connection. It is adapted for DSH 0.2.1-rc.2. In system mode on Windows 10/11, it reads the registry; on non-Windows systems, system mode only reads startup environment variables.

Core Features

Routing Strategy

Capability Description
Model Requests When keepModelDirect: true (default), deepseek.com is always in NO_PROXY, and model traffic goes direct.
web_fetch Goes through dsh-web-fetch-http; calls proxyRouteFor(url) for every request. Changes take effect immediately.
Regular fetch() Reads the global undici dispatcher, consistent with the above strategy.
Subprocesses Follows the exported HTTP(S)_PROXY / NO_PROXY.

Three Modes

Mode Behavior
direct No proxy installed; everything connects directly.
system On Windows, reads ProxyEnable / ProxyServer / ProxyOverride from HKCU\...\Internet Settings (consistent with Clash “System Proxy”).
manual Uses the HTTP(S) proxy address specified in the proxy config.

Health Check: Performs TCP probes on the proxy based on probeIntervalMs; if fallbackToDirect: true, it switches to direct connection upon failure and automatically switches back after recovery.

Web UI

Settings → General → Outbound Routing provides:

  • Dropdown: All Direct / Follow System / Manual Proxy;
  • Proxy address input for manual mode;
  • “Keep Model Requests Direct” checkbox.

Saving writes to the profile’s cordis.patch.yml. The Host receives the config update and reinstalls the policy without needing to restart DSH.

If the environment variable DSH_EGRESS_DISABLE=1 is set, the plugin completely backs off.

Installation and Enablement

Desktop profiles are managed by the desktop application. The README recommends prioritizing manual installation (tested); the bundle method can be verified via a lab profile first.

  1. Download dsh-egress-router-0.1.1.zip from Releases and extract it.
  2. Copy lib/ and package.json to the profile’s node_modules directory.
$src = ".\dsh-egress-router"
$dst = "$env:USERPROFILE\.dsh\profiles\desktop\node_modules\dsh-egress-router"
New-Item -ItemType Directory -Force $dst | Out-Null
Copy-Item "$src\lib" $dst -Recurse -Force
Copy-Item "$src\package.json" $dst -Force
  1. Append the plugin block to the end of %USERPROFILE%\.dsh\profiles\desktop\cordis.patch.yml:
- insert:
    - id: egress-router
      name: dsh-egress-router
      config:
        mode: system
        proxy: http://127.0.0.1:7897
        keepModelDirect: true
  1. Completely exit DSH (including the system tray) and reopen it.

Method B: Bundle Installation

Available after publishing to npm:

dsh plugin --profile web add dsh-egress-router

Or in the Web UI: Settings → Plugins → Add Plugin, enter dsh-egress-router. web is just an example profile name; please replace it with your own profile. For desktop, use the Web UI “Add Plugin”; do not use dsh plugin --profile desktop.

This package contains dsh.bundle.patch; bundle installation will automatically create the egress-router entry. Do not manually write the insert from Method A again, otherwise the same ID will be duplicated.

Configuration

Field Default Description
enabled true Master switch; restores startup policy when false.
mode system direct / system / manual
proxy http://127.0.0.1:7897 Proxy for manual mode, strictly http:// / https:// only.
keepModelDirect true Adds deepseek.com to NO_PROXY.
noProxy [] Additional direct hosts (does not support 192.168.* network segment syntax).
fallbackToDirect true Fallback to direct connection when proxy is unavailable.
probeIntervalMs 5000 Probe interval; 0 disables it.
probeTimeoutMs 800 Single probe timeout.

Clash mixed port example: http://127.0.0.1:7897. Only HTTP(S) proxies are supported; SOCKS will be rejected by @deepseek-ai/dsh-http-proxy.

Typical Usage and Verification

After the installation and configuration above, you can self-test as suggested in the README:

  1. Send a conversation to the model and receive a normal reply → Model direct connection works.
  2. Ask the agent to fetch https://en.wikipedia.org/robots.txt, return 200 → External fetching goes through the proxy.
  3. See “Outbound Routing” in the settings page → Client module loads normally.
  4. Turn off Clash, wait about 5–10 seconds, then try to fetch the external network → A network error should appear instead of a long freeze; it should automatically recover after turning Clash back on.

Use Cases and Notes

Suitable for Windows users who need to separately manage model and external fetching within the same DSH session and commonly use HTTP proxies like Clash. macOS / Linux users can use direct / manual, but system mode will not read the system proxy registry.

The plugin runs with the current DSH process permissions. Please review the source code and MIT license yourself before installation. Do not write proxy URLs with account passwords (they will be written to the profile in plaintext). Known limitations include: network segment rules in ProxyOverride cannot be fully expressed, and Clash fake-ip might trigger DSH private address validation during “fallback to direct,” etc. See the README “Known Limitations” for details.

Rollback: Completely exit DSH → Delete the - insert: block for this plugin in cordis.patch.yml → Restart; optionally delete profiles\<name>\node_modules\dsh-egress-router.

Conclusion

dsh-egress-router consolidates “Model Direct + Fetch via Proxy + Health Fallback + UI Switching” into a single Cordis plugin, reducing the friction of modifying .env and restarting. The community plugin directory SkillHub and the repository fengyevvv/dsh-egress-router are independent ecosystem entry points and have no official affiliation with DeepSeek / Hithink RoyalFlush. DSH itself continues to follow the “Everything is a Plugin” extension approach and can be selected according to needs.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye