In DeepSeek Harness (DSH), the execution trajectory of an AI Agent is recorded, but raw logs often contain a lot of noise and lack structured readability. Developers find it hard to quickly review decision points or learn from mistakes. The dsh-trajectory-teacher plugin solves this problem by automatically converting raw trajectories into a structured retrospective report.

This plugin is maintained by XiaoMoDern, categorized as a workflow plugin, and uses the MIT License.

Installation and Enabling

Installing the plugin requires the DSH plugin command.

dsh plugin add dsh-trajectory-teacher

After installation, DSH must be restarted for the plugin to be mounted automatically.

Usage

When using it, first complete a round of task in the conversation. Then enter the command to trigger the retrospective.

/trajectory-teacher

The plugin analyzes the complete trajectory of the current session and returns a retrospective report in Markdown format. The retrospective is manually triggered to control LLM token costs.

Core Functions

The plugin provides the following core functions:

  • Automatically converts Agent execution trajectories into retrospective reports.
  • Extracts key events, including decision points, pitfalls, and reusable practices.
  • Automatically redacts sensitive data, handling plaintext API keys that may appear in trajectories.
  • Filters noise and keeps only key events.
  • Supports custom model configuration.
  • Disables thinking by default to control costs.

Optional Configuration

By default, it reuses the model currently used by the session to generate the retrospective. To specify one, override it in cordis.patch.yml.

- id: trajectory-teacher
  config:
    provider: deepseek-official
    model: deepseek-v4-flash

The retrospective analysis disables thinking by default (reasoningEffort: 'off') — extraction + summarization does not require deep reasoning, making it faster, cheaper, and producing more stable output.

How It Works

The processing flow is as follows:

  1. Extraction: Starts from session.events (in-memory event stream). Filters noise (discards token-level chunks), extracts key events (tool/call, assistant/message, turn/*, approval/*, etc.), summarizes them, and redacts sensitive data.
  2. Analysis: Calls an LLM to produce structured JSON (including decision points / pitfalls / reusable practices).
  3. Rendering: Applies a template to generate Markdown.
  • Noise filtering: One streaming response may produce hundreds of token-level chunks; all are discarded, keeping only key events.
  • Redaction: Trajectories may contain plaintext API keys; they are automatically masked before report output (sk-***).
  • Cost control: Manually triggered (not run automatically), only feeds a summary of key events (with a length limit), disables thinking, and uses a cheap model.

Project Structure

The project mainly contains the following files:

  • index.ts: Plugin entry point, registers the /trajectory-teacher command.
  • cordis.patch.yml: Patch layer for the bundle.
  • lib/parse.ts: zstd decompression + event stream parsing.
  • lib/extract.ts: Noise filtering + key event extraction + summarization + redaction.
  • lib/analyze.ts: Calls an LLM to produce a structured retrospective.
  • lib/render.ts: Converts JSON to Markdown.

Development and Debugging

Local debugging (mounting from source code into DSH):

cd <deepseek-harness 源码根目录>
pnpm dsh web --patch <本仓库>/dev/cordis.patch.yml --port 0

Run tests and build:

npm test
npm run build

Notes

Retrospective analysis consumes LLM tokens and requires manual triggering. DSH must be restarted after installation. API keys are automatically masked before output. Ensure you check the source code and license before installing.