Skills Plugins MCP Prompt Model 导航 博客 资讯 我的中心
工具与能力 #dsh-plugin#dsh-plugins#dsh

dsh-cwl

CWL — Context Window Lifecycle for DeepSeek Harness: structured context eviction (arXiv:2606.11213). Graduated, deterministic, zero-LLM eviction of exploration/action episodes when context pressure exceeds budget — no summarization lossiness, no hallucina

kalifun @kalifun ⬇ 1 ★ 0 main

安装

dsh plugin --profile web add github:kalifun/dsh-cwl
下载安装清单

需要可复现安装时,可在仓库后追加 #commit 固定提交。

CWL — Context Window Lifecycle for DeepSeek Harness: structured context eviction (arXiv:2606.11213). Graduated, deterministic, zero-LLM eviction of exploration/action episodes when context pressure exceeds budget — no summarization lossiness, no hallucina

该插件未提供要点说明,请参考仓库 README。

dsh-plugindsh-pluginsdsh
  1. 安装并启动 DeepSeek Harness:npx @deepseek-ai/dsh web
  2. 在终端执行上面的安装命令(CLI 会解析插件并核验来源)
  3. 用 dsh plugins list 确认已安装,必要时重启 Harness 生效

插件以当前 dsh 进程的权限运行,安装时可能执行代码。请先通读仓库源码与许可证,确认无破坏性命令与越权访问;本站只做索引,不对第三方插件安全性作担保。

代码仓库github.com/kalifun/dsh-cwl
许可证MIT
主要语言main
下载量1
GitHub 星标0
最近推送2026-09-04
收录日期2026-09-19
分类工具与能力

事实信息来自公开插件目录快照(2026-10-01),介绍文案由本站再加工。

以下为插件仓库 README 全文(原始内容,由公开目录抓取整理)。

# dsh-cwl

**CWL — Context Window Lifecycle** for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness):
structured context eviction for long-horizon agents.

> Paradigm: [*Beyond Compaction: Structured Context Eviction for Long-Horizon Agents*](https://arxiv.org/abs/2606.11213) (arXiv:2606.11213, Kiz8)

**English** | [简体中文](./README.zh-CN.md)

## Why not summarization compaction?

Compaction (the standard response to context pressure) summarizes history with an LLM.
Four structural problems (per the CWL paper):

- **Unpredictable lossiness** — the summarizer decides what matters, not the task.
- **Structural destruction** — causal chains (tool call → output → decision → action) collapse into prose.
- **Blocking cost** — a full LLM call fires mid-task, under token pressure.
- **Compression-induced hallucination** — summarization under length pressure is a known failure mode.

CWL treats the transcript as a **structured record of work** and evicts deterministically:
the agent's trajectory is inferred into a **typed episode graph** (exploration `expl` / action `act`,
with dependency edges), and when context pressure exceeds budget, a **zero-LLM, deterministic policy**
strips content in graduated levels — exploration episodes first (pure context, safest), then action
episodes whose effects are already persisted. **User messages are never evicted.**

## How it works

1. **Episode inference (automatic, no agent annotation needed)**: consecutive same-type tool
   batches merge into semantic episodes (`expl` for pure read/search — including read-only
   `bash` like grep/cat — `act` for anything with side effects: edit/write/write-style bash).
   Each user message closes the current episode (a turn boundary), and episodes are capped at
   a batch limit, so even a single-request long autonomous run (dozens of tool calls) splits
   into bounded, evictable segments instead of collapsing into one giant episode. An `act`
   that touches files an earlier `expl` read gets a dependency edge.
2. **Pressure metering**: real context pressure = input + cacheRead + output + reasoning tokens
   (accumulated from `assistant/message` usage events — `tokenMeter.measure().totalTokens` omits
   cacheRead, which dominates long sessions).
3. **Graduated eviction** on the `agent/pre-step` waterfall (before every LLM call), from
   fine to coarse:
   - **content stubbing (fine)**: large tool-result contents in `expl` episodes are rewritten
     to a short stub first (`[cwl-stub: …]`) — structure kept, tokens cut, tool pairing intact
   - **whole-episode eviction (coarse)**: `expl` episodes first (pure context, one-line
     "explored: …" marker), then completed `act` episodes; executed as **positional blocks**
     in the surface (positions are the invariant that survives replaces — an eviction never
     splits a tool-call/result pair into orphans)
   - never touch the newest tail (preserve-recent) or user messages
   - evicted ranges are replaced with a lightweight marker via the official surface-replace
     seam (original events stay in the log; `cwl_recall` can restore file paths)

## Install

```bash
dsh plugin --profile  add dsh-cwl                 # from npm
dsh plugin --profile  add github:kalifun/dsh-cwl  # or from GitHub
```

Or vendor the directory and add to your composition:

```yaml
- id: dsh-cwl
  name: ./dsh-cwl/index.js
```

## Usage

No configuration needed. It stays completely inert while context is under budget
(default 80% of the model's context window), and starts evicting only when pressure
exceeds budget.

```bash
# Optional: override the budget (tokens) — for testing pressure behavior
DSH_CWL_BUDGET=30000 dsh web
```

Eviction policy (deterministic cache-replay validation: eviction −24% cacheRead,
strategy-independent; batch best mean −24.7%, consistent across 7 sessions → defaults
below; override via env):

| Env var | Default | Values | Effect |
|---------|---------|--------|--------|
| `DSH_CWL_EVICT_ORDER` | `tail` | `tail` / `oldest` | `oldest` evicts oldest episodes first |
| `DSH_CWL_EVICT_BATCH` | on | `0` / `false` / `off` to disable | merge adjacent episodes into one surface replace (fewer cache breaks) |
| `DSH_CWL_EVICT_TAIL_WINDOW` | 0 | `N` | only evict episodes whose end falls within the last N surface nodes |
| `DSH_CWL_STRIP` | on | `0` to disable | fine-grained level: stub large tool-result content in expl episodes before whole-episode eviction (structure preserved) |
| `DSH_CWL_STRIP_THRESHOLD` | 1500 | chars | minimum result text length to be stubbed |

```bash
# back to the conservative config (oldest, per-episode replaces)
DSH_CWL_EVICT_ORDER=oldest DSH_CWL_EVICT_BATCH=0 dsh web
```

Session analysis (per-round token breakdown + "cacheRead of the round after an eviction"):

```bash
node tools/analyze-session.mjs
```

Agent-facing tools:

| Tool | Purpose |
|------|---------|
| `cwl_recall` | list file paths touched by evicted episodes, to re-read on demand |

Observability:

| Endpoint | Purpose |
|----------|---------|
| `GET /api/cwl/evictions` | eviction log (session → episodes evicted) |
| `POST /api/cwl/force` | debug: force one eviction on a session |

## Verification

```bash
node check.js          # pure-function unit checks (episode inference, eviction policy, strip, pairing)
```

Live capability benchmarks (helmsman platform): **[BENCHMARKS.md](./BENCHMARKS.md)** —
the fixed test plan (scenario A: 12-round long conversation; scenario B: single-request
long autonomous task ×3) with per-version data rows, refreshed after every behavioral change.

Offline regression tools (run on your own local sessions — no data leaves your machine):
`tools/cache-replay.mjs` (deterministic cacheRead), `tools/replay-real.mjs --apply` (engine
apply-layer with real surface fold + tool-pairing assertion), `tools/eval-episodes.mjs`.

## License

MIT

数据来源:公开的 DeepSeek Harness 插件目录与各插件 GitHub 仓库。本站为独立第三方目录,与 DeepSeek、幻方(High-Flyer)及插件作者均无隶属或背书关系。

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。