dsh-router-agent: Project-Level Router Agent Plugin

Preface

DeepSeek Harness (DSH) allows users to maintain multiple sessions within a single project. Changes to the same feature are often scattered across multiple sessions. Once the context grows too long, users are forced to start a new session, and the Agent must re-read the code from scratch. This leads to fragmented context, task-hopping, and difficulty tracing lineage. A unified routing layer is needed that, upon receiving a task, automatically determines whether to continue an existing session, fork from a specific turn, or start a clean new session.

What It Is

dsh-router-agent is a project-level Router Agent (RA) plugin maintained by fakeNihilist, categorized under workflows. It transforms a project’s sessions into a set of routable context units: when a task arrives, the Router decides whether to continue an existing session, fork from a specific turn, or create a clean new session—rather than forcing the user to guess which one to open.

The RA does not read code or write code. It only reads indexes and submits proposals; by default, it must receive user confirmation before sending.

Core Features

  • Infinite canvas view: Root nodes are arranged by their respective last-active timestamps; forks extend downward (vertical, default) or to the right (horizontal).
  • Context occupancy visualization: Each node displays context occupancy (percentage + 2px bar + compression icon), with color changes at 60/85 thresholds.
  • Details omit overview, one-liner, lineage, or branch count: Parent-child relationships are expressed solely through connecting lines and fork points.
  • Routing decision: Continue / Fork / New / Clarify. Forks target a specific turn/end’s atSeq; users can adjust the fork point in the proposal card.
  • Tracking scope: Defaults to tracking only the last 7 days; older sessions enter “Untracked Sessions”; checking consent restores them, and they re-enter the RA context.
  • Project switching: The project dropdown lists all projects; after selection, the canvas and untracked list show only that project’s sessions, and the view re-fits.
  • Stopping a parent session only stops the parent itself: Tracked child sessions move to the top level and continue tracking; after restoring the parent session, they automatically re-attach.
  • Plan mode / workspace permissions: The dispatch settings in the input area apply per session; the proposal card shows the target’s current settings and the changes about to occur.
  • Auto-execute: Disabled by default; once the user explicitly enables it, after the RA makes its decision, the Host validates the target’s lastSeq (fail-closed rejection if unreadable) and sends directly without further confirmation.
  • Dispatch history: Task, action, target, reason, result (sent/created/forked/auto-executed/not executed/failed).
  • First-time index pre-generation: Only indexes within the tracking scope, showing progress; Host restarts resume the queue, queue failures show a retryable failed status, and single-session failures degrade to extractive indexing.
  • Bypass updates: When users continue sessions directly in DSH, indexes and the canvas refresh with log-revision debouncing after turn/end.
  • Native compaction: Invokes DSH’s /compact (or ctx.compaction.compactNow); does not fake success; clearly indicates when running or unavailable.
  • Theme & narrow screens: Uses --dsw-* tokens, consistent across dark/light modes; dropdowns are custom-drawn (same font size in closed and expanded states); container queries adapt to narrow panels, zoom controls move above the input area and are never obscured.

Installation & Setup

Requirements: DSH Desktop 0.2.2-rc.x (session format V4), Node >=22.19.

git clone https://github.com/fakeNihilist/dsh-router-agent.git
cd dsh-router-agent
npm install
npm run build

# Install into desktop profile (link to current repo)
dsh plugin --profile desktop add link:"$PWD"

# Restart DSH Host; refresh the page after client-side changes
# If desktop cache is corrupted, only clear Cache / Code Cache in %APPDATA%/@deepseek-ai/dsh-desktop

The plugin registers:
- One Host plugin entry dsh-router-agent;
- One Agent preset router (display name Router);
- A browser-side main panel (keyed main) and a sidebar entry Router.

Typical Usage

  1. Open a project with existing sessions in DSH.
  2. Click Router in the sidebar.
  3. On first entry, a session index for the last 7 days is built; once complete, nodes appear on the canvas.
  4. Type a task in the bottom input field and press Enter to send it to the RA.
  5. After the RA calls ra_tree / ra_brief, it presents a proposal:
    - Continue: The target session receives the task;
    - Fork: A child session is created from Tn’s atSeq; the child node is placed below/right of the parent;
    - New: A clean session where the first message is the task itself, with no handoff package;
    - Clarify: Presents a clear choice; after the user answers, the RA continues its evaluation.
  6. By default, click “Confirm & Send”; with “Auto-execute” enabled, no confirmation is needed, but the result is still recorded in the dispatch log.

Input Area

  • Mode: Standard / Plan mode. Plan mode takes effect on the target session via the /plan command; the card deliberately displays the target’s current state.
  • Workspace permissions: Read-only / Modify within workspace / Full access. Applied to the target session via permissionPresets.set.
  • Auto-execute: Off by default; once enabled, the RA can no longer use ask and must directly choose route/fork/new. The toggle retains the “Auto-execute” label, with a custom tooltip shown on hover.
  • Cross-target changes: If the target session has new events after the proposal, the Host returns 409 target-changed on confirmation, preventing the task from being sent to an already-changed context.

Settings

Gear icon:
- Node layout: Vertical (roots left-to-right, forks downward) / Horizontal (roots top-to-bottom, forks to the right).
- RA model: Only affects the Router session; applied via agent.model.select, does not change the deployment default.
- Default model for new sessions: Only used for sessions created or forked by the Router.
- Both model dropdowns list deployment models directly; when no selection has been saved, the deployment default model is pre-selected; the “Follow deployment default” option is no longer offered.

Untracked Sessions

“More” next to the clock → “Untracked Sessions”. By default, only the last 7 days are tracked; manually stopped sessions also appear here. The list shows only the currently selected project’s sessions; after checking the consent checkbox (multi-select supported) for entries to restore, click “Restore Selected” to write back to .dsh_RA’s pinned and re-enter the tracking scope. The restore button remains disabled when nothing is checked. The list area scrolls independently with a fixed bottom action bar; the modal has a max-height limit so many entries don’t overflow the panel.

Security Boundaries

  • RA has only 4 tools: The preset’s plugins attach a native executor + router-tools; router-tools uses a deny list to hide inherited global tools, refreshes on tools/change (covering tools dynamically registered later, such as MCP), and uses tools.guard as an execution fallback allowing only ra_*. No fs / bash / web / subagent / workflow; run_code is not exposed even under PTC deployments.
  • Proposal and send are separated: ra_propose only writes proposals/<token>.json. Sending is executed by the Host after user confirmation; auto-execute must be explicitly enabled by the user. Confirmation claims executing via compare-and-set; concurrent requests execute only once; fork/new sessions that fail after creation are marked failed and will not be retried into a second child session.
  • Token + lastSeq validation: On confirmation, validates token, expiry, project, and target’s last event seq; rejects execution if the target log is unreadable (fail-closed).
  • No history rewriting: Briefs, tracking, settings, and history all reside in the project sidecar .dsh_RA; the RA never renames routing targets. Briefs and dispatch history redact sk-…, Bearer …, and key-value credentials.
  • Does not overwrite meaningful titles: Only explicitly provided titles at creation/fork time trigger native rename; user manual renames write to the sidecar and best-effort sync the native title.
  • Compaction is a user action: Not routed through the RA; requires a live idle agent; failures are returned as-is, never faked as success.

Data Storage

Project root .dsh_RA/:

.dsh_RA/
  .gitignore
  state.json                 # tracking/stopping/settings/RA session/lineage/titles/onboarding
  sessions/<id>.json         # internal brief (no overview rendered)
  proposals/<token>.json     # RA proposals
  dispatch.jsonl             # dispatch history
  diagnostics/probe.json     # capability probe

This is an intentional exception to DSH’s official storageDomain: the product requires data to follow the project. The plugin implements its own atomic writes (temp + rename), in-process and cross-Host file locking, concurrent brief writes, and .gitignore; .dsh_RA/.gitignore contains only *, so the directory does not appear in git status. dispatch.jsonl retains the most recent maxHistory (default 100) entries; expired proposals/briefs are periodically cleaned up.

Capability Probing

On first load / after each DSH upgrade, probeHost(ctx) records (reading state refreshes the current result):

  • sessionController list/create/fork/prompt/projections/modelCatalog/selectModel/rename
  • sessionQuery read/observe/inspect/list
  • sessionProjections.snapshot
  • compaction.compactNow / commands.execute
  • planMode / permissionPresets / sandboxPolicy / approval
  • llm.stream
  • connection.fetch.register / webServer.register
  • tools.register/restrict/guard / systemPrompt.section
  • agentPresets / sessionTitle / workspaceRegistry

GET /api/router/probe returns the current process’s results; the UI uses probe data to drive disabled states.

Applicable Scenarios & Notes

Suitable for scenarios where you maintain multiple sessions in DSH and need unified routing decisions. The plugin runs with the current dsh process’s permissions; review the source code and license (MIT) before installation.

Conclusion

dsh-router-agent, through project-level routing, session-level dispatch, automatic indexing, and a visual canvas, organizes scattered sessions into routable context units, enabling the Agent to automatically choose whether to continue, fork, or create a new session when a task arrives—reducing context fragmentation and improving collaboration efficiency.

Directory Page | GitHub

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

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

Xiaoye