@ray1270/dsh-task-stack: Provides a Persistent Multi-Step Task Stack for DSH Agent

Introduction

A common pain point when running Agents in DeepSeek Harness (DSH) is: a single request often hides several separately deliverable goals, and the conversation is long. Once context is compacted, the model easily “forgets” which layer of goal it currently owes the user, and which subtasks have already been closed. Hard-coding “current task” into the system prompt consumes tokens and doesn’t align with the user’s real multi-step stack structure.

@ray1270/dsh-task-stack (maintained by Ray1270, categorized as “memory” in the community directory) gives Agents an explicit task stack: three tools—push / pop / inspect focus—with state stored as plain-text JSON in the session workspace; no automatic injection into system prompts or context—if the Agent doesn’t call them, no extra tokens are spent. For npm package version, see @ray1270/dsh-task-stack (the package in the materials is 0.2.0).

What This Is

In one sentence: a persistent, session-isolated task stack for DeepSeek Harness Agents, paired with the human-facing slash command /focus for debugging or manual cleanup.

  • Survives context compaction: state lives on disk, so compacting the conversation doesn’t lose the stack.
  • Session recovery: remounting with the same sessionId and cwd reads back the same file.
  • Zero automatic injection: writes no system prompt, injects no context.

State file path: <session-cwd>/<stateDir>/<sessionId>.json (default stateDir is .dsh/task-stack).

The Three Agent Tools

The model-side tool descriptions are written according to “when to use / when not to use / what is returned”.

focus_task(description)

Pushes a one-line task description onto the top of the stack; the previously active task becomes paused. Returns the new stack depth and the top task.

  • Use when: delivery requires multiple steps, especially when one request contains multiple separable goals; push the outermost goal you owe the user, not each internal step.
  • Do not use: for single-turn Q&A, routine steps internal to the current top task, or paraphrasing the user’s message.
  • When the stack depth reaches maxStackDepth, reject and explain the reason; do not throw an exception.

focus_complete(conclusion)

Pops the top of the stack, records the conclusion, and the next layer becomes active again. Returns the closed task, the reactivated task, and the remaining depth.

  • Use when: the multi-step work at the top of the stack is done and the deliverables are in place, and you call this before writing the final answer.
  • Do not use: to abandon, pause, or rename; if the goal changes, rephrase the top of the stack rather than leaving it open.
  • On an empty stack, reject and indicate that no task was pushed for this piece of work.

read_focus()

Returns the full stack (active + paused) and the most recent few completed records in markdown.

  • Use when: after context compaction, when resuming a session, when the user asks “what are you doing”, or before deciding whether to push or complete.
  • Do not use: calling it every step; unnecessary when the focus has been visible in the last few turns.
  • This plugin does not inject prompts; this is the primary way for the Agent side to inspect the task stack.

Typical nesting (from the README example):

focus_task("Add a JSON import command to the CLI")
   └─ encounters a multi-step goal that needs to be completed separately → focus_task("Also fix the import error messages")
        └─ focus_complete("Error messages fixed, with unit tests")
   ← stack top returns to "Add a JSON import command to the CLI", becomes active again
focus_complete("Import command added, smoke test passed")

/focus Slash Command (human-facing, does not consume model tokens)

Besides the three tools, the plugin registers /focus, operating directly on the current session’s task stack.

Input Effect
/focus Prints the task stack (active/paused + depth) and recent history
/focus done <conclusion> Closes the top of the stack and writes to history, equivalent to focus_complete
/focus clear Clears the entire stack; each cleared task is recorded in history (conclusion is cleared via /focus)

/focus clear is idempotent on an empty stack; /focus done on an empty stack explicitly states the stack is empty.

Installation and Activation

In the DSH ecosystem, plugins are typically installed via a profile bundle; after restarting DSH Desktop, new sessions will allow the model to call the three tools and use /focus.

Recommended installation from npm:

dsh plugin --profile desktop add @ray1270/dsh-task-stack

After installation, dsh plugin add places the package into the profile’s node_modules and registers it in the profile’s package.json under dsh.profile.bundles; the profile applies the bundle’s cordis.patch.yml, and the load line name: @ray1270/dsh-task-stack resolves from the profile’s node_modules.

For development and debugging, you can use the launcher overlay (no installation; note that --patch must come before the profile name):

dsh --profile web --patch ".\dev.patch.yml" --no-open

A common mistake: dsh web --patch x.yml (the web subcommand does not recognize --patch); you should use dsh --profile web --patch x.yml.

Configuration (Optional)

Configure under the plugin entry’s config: in the profile patch layer; Cordis validates before the plugin starts, rejects loading on out-of-range values, and indicates the offending field in the startup log.

Field Default Meaning
stateDir .dsh/task-stack State directory, relative to the session workspace
maxStackDepth 20 Maximum number of simultaneously open tasks on the stack
historyLimit 100 Maximum number of completion records, trimming from the oldest
statePruneDays 0 (0 = no cleanup) On load, delete session state files not written to for more than N days

Example:

- insert:
    - id: @ray1270/dsh-task-stack
      name: @ray1270/dsh-task-stack
      config:
        stateDir: .dsh/task-stack
        maxStackDepth: 20
        historyLimit: 100
        statePruneDays: 30

Read-Only Snapshot Under Web Composition

Under dsh --profile web, the plugin additionally registers a read-only HTTP endpoint for the GUI to read the task stack:

GET /api/dsh-task-stack/snapshot?sessionId=<id>&cwd=<absolute path>

The returned JSON includes depth, top, stack, history, warnings, etc.; unauthenticated requests or a Host outside the trusted scope return 401/403; without a connection service it returns 503 (fail-closed). The endpoint is read-only; writes still go through focus_complete or /focus.

Applicable Scenarios and Notes

Suitable for: Harness Agent workflows with long conversations, nested multi-goals, and the need to recover the “current focus” and completed conclusions even after context compaction.

Notes:

  1. The plugin reads and writes JSON under the workspace with the current DSH process’s permissions; before installing, review the GitHub source code and the MIT license to confirm it meets your security policy.
  2. Node engine requirement: ^22.19.0 || >=24.0.0 (see package.json).
  3. The community directory skillhub.cn is an independent site, with no official affiliation with DeepSeek / High-Flyer; metadata such as star counts is based on each site (the clue indicates 2 stars on GitHub).

Links

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

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

Xiaoye