Architecture / 事件流说明

August 19, 2026 · View on GitHub

Goal

In DeepSeek Harness 0.1.0-rc.7, manual /compact summarization target resolution is configured ?? current ?? latest ?? agentTarget. An explicit summarizationProvider / summarizationModel therefore overrides the frontend's currently selected model. This bundle adds a hard override for the manual conceptual compaction span only.

Why a host-plane interceptor?

Replacing or forking @deepseek-ai/dsh-compaction-basic would duplicate the compact engine and break when upstream changes it. DSH profiles are Cordis compositions, so the same effect can be achieved by observing two existing events:

  • session/event (compaction/start / compaction/end) marks the exact span whose summarization request should be intercepted.
  • llm/stream (waterfall order) lets middleware mutate the same options object that the LLM adapter will resolve, which is why changing options.provider / options.model before yielding next() works.

Manual vs automatic compaction

The durable signature of an explicit /compact request is a compaction/start session event whose data.turn === null. Automatic compaction has a numeric turn. This bundle only tracks the former and never touches regular chat turns, frozen LLM requests, or automatic compaction.

Event flow

  1. session.append dispatches session/event synchronously before the summarization call, so activating the session never races the LLM request.
  2. The llm/stream handler checks purpose === 'compaction', the session id, the active marker, and Object.isFrozen(options) before mutating anything.
  3. agentDefaultModel.currentSelection() supplies the frontend-selected provider/model; if it is unavailable the stream passes through untouched.
  4. The wrapper generator restores the caller's provider / model fields in a finally once delegation returns.

Compatibility boundaries

  • The compaction/start owner marker (turn: null) and the llm/stream compaction request shape are rc.7 behavior; review before upgrading DSH.
  • The bundle is runtime-import-free by design.

Uninstall

dsh plugin --profile web remove @dsh-external/dsh-compaction-current-model removes the inserted row and restores the default composition.