ChatGPTClaudeGrok / X / CursorGemini

DSH plugin reference cancel: no publish, even after storage

Plugin DevelopmentPublished 2026-11-10Author: DeepSeek Plugin Market
DSH pluginDeepSeek Harnesssession referencecancellationsignal
Cancellation does not mean stopping fast; it means never publishing a context, even if storage finishes afterward. Signal scope, timing, and two race tests.

Cancellation does not mean "stop as fast as possible"; it means "do not publish even if the result is already computed". DSH plugin guarantees that storage completing after a cancel still will not put context into the message. Without a signal from the host, that guarantee does not exist.

DeepSeek Harness: The user stopped, but context still appeared

First check whether the signal reached prepare. (source) Scene:

text
User clicks stop
Host resets UI state but never aborts the request
prepare keeps running, storage completes, context publishes
The next message carries referenced content

From the user's view, it kept running after stopping; in the chain, cancellation stopped at the UI layer.

Diagnose by logging the error branch: look for SESSION_REFERENCE_CANCELLED. If it never appears, cancellation never arrived.

DeepSeek Harness: Where the cancellation boundary sits

On one prepare call, not globally. (source) Rules:

  1. prepare(agent, content, references, signal) takes an optional signal;
  2. When passed, it is the cancellation boundary for this turn;
  3. Cancellation affects this preparation only, not other messages;
  4. Without a signal, prepare never guesses that the user might want to stop.

The fourth point means cancellation is a host responsibility, not a service default.

DeepSeek Harness: Storage completion vs cancellation

Two orders; both must end in "do not publish". (source) Comparison:

OrderStorageCancellationResult
1Completes firstArrives laterNot published
2Completes laterArrives firstNot published

The second is the hard case: when cancellation arrives, data is still being written, but finished data is still unusable.

The official wording is direct: cancellation prevents publication, including when storage completes after cancellation.

Implementation-wise this requires checking cancellation again before publishing, not only at the entry.

DeepSeek Harness: Which error code to return

Return SESSION_REFERENCE_CANCELLED; never an empty context. (source) Three reasons:

  • An empty context means "no referenced content", which is a different meaning;
  • The code lets callers distinguish a user stop from an empty reference set;
  • Logs can measure cancellation frequency and inform UX work.

Swallow the cancellation and return success, and the user sees context appear on the next message.

The reverse is also wrong: returning CANCELLED for every failure hides real problems. Use the code that matches the cause.

DeepSeek Harness: Four host actions after cancel

Four things, in order. (source) Steps:

  1. Stop writing this preparation's result into the message;
  2. Keep the user's selected references but mark them "not applied";
  3. Do not retry automatically unless the user sends again;
  4. Record the cancellation reason to separate manual stops from timeouts.

The second is easy to miss: after cancelling, a resend should not require reselecting everything.

The fourth is useful product data: frequent cancellations may mean preparation is slow, not that users are fickle.

One timing detail remains: check the signal again before publishing. Check only at entry and storage can finish after the cancel, letting context slip into the message anyway.

DeepSeek Harness: Testing the race

Two race cases plus a control. Steps:

  1. Cancel right after preparation finishes and confirm no context is published;
  2. Cancel mid-preparation, delay storage so it completes after cancel, and confirm no context is published;
  3. Pass no signal and confirm normal publication as a control.

Case 2 needs artificial storage delay; otherwise it is hard to trigger.

Case 3 proves the test harness is not cancelling by accident.

Three passes mean cancellation is checked both at the entry and before publication.

After cancellation comes the security boundary. Read why DSH plugin marks referenced context untrusted; for error mapping, read the seven DSH plugin reference error codes; for the wider picture, read how DSH plugin implements session references.

Sources: DeepSeek Harness reference - Session references, session-reference/src/index.ts

ChatGPTClaudeGrok / X / CursorGemini

FAQ

In DSH plugin, the user pressed stop but the next message still carried referenced context. Why?

Most likely the signal never reached DSH plugin prepare. DSH plugin publishes nothing after cancellation, but only if the host actually passes a signal and aborts it; cancelling UI state alone does not stop the request.

What does DSH plugin return when cancellation happens?

DSH plugin returns SESSION_REFERENCE_CANCELLED when cancellation happens. Returning an empty context instead blurs user cancellation with an empty reference set and hides the event from logs.

With DSH plugin, does cancellation also stop work that already finished?

The DSH plugin guarantee is about publication, not about undoing work. Even if storage completes after the cancel, the context must not be published.

In DSH plugin, how is file reference cancellation different?

DSH plugin file reference cancellation stops discovery, while session reference cancellation blocks publication of prepared context. They share the signal shape but act at different stages.

Related Terms

signal
The optional signal on prepare marks the cancellation boundary for one turn.— DeepSeek Harness reference - Session references
SESSION_REFERENCE_CANCELLED
SESSION_REFERENCE_CANCELLED is the stable error code returned when a session reference call is cancelled.— DeepSeek Harness reference - Session references
publication
Publication is the step that places prepared context into the message; cancellation blocks it regardless of storage timing.— session-reference/src/index.ts
race window
The race window is the interval between starting preparation and publishing, during which a cancellation may arrive.— DeepSeek Harness reference - Session references

Sources