ChatGPTClaudeGrok / X / CursorGemini

DSH plugin normalization: what happens before prepare

Plugin DevelopmentPublished 2026-11-10Author: DeepSeek Plugin Market
DSH pluginDeepSeek Harnesssession referencenormalizationcontent
Referenced text that differs from the original is usually changed upstream. What hosts must normalize, what they must never touch, and a boundary table.

"The referenced content was rewritten" almost always happens before prepare is called: a host folds normalization and cleanup into one step and processes bytes that should have been preserved. DSH plugin's boundary is simple: the host shapes input, prepare removes markers, and the snapshot preserves bytes.

DeepSeek Harness: Referenced content does not match the source

Look in host preprocessing first, not in the service. (source) A typical scene:

text
source:    const  x = 1   // two spaces
reference: const x = 1    // one space

If the host merged consecutive spaces before submit, the snapshot differs. The service did not rewrite anything; upstream did.

The test: hand the same content to prepare without host processing and compare. Identical results point at host processing; differences that persist point at the service.

DeepSeek Harness: Three processing stages

Three stages with separate owners; folding them together cancels each other out. (source) Comparison:

StageOwnerWhat it does
Input normalizationHostConverts editor content into readable blocks
Token removalprepareDeletes mention markers from the body
Snapshot preservationprepareCarries referenced content byte-for-byte

Stage one produces content; stages two and three happen inside prepare.

Many teams move token removal into stage one, after which prepare cannot find the markers and loses the ability to tell body text from reference markers.

DeepSeek Harness: Three things hosts should normalize

Handle input shape only, never semantics. (source) Three items:

  1. Editor structure — turn rich text, lists, and code blocks into content blocks;
  2. Private markers — remove placeholders that exist only for UI display, but keep mention markers;
  3. Invalid control characters — clean characters that would break parsing.

Be careful with the third: remove only genuinely invalid characters, and do not treat tabs or newlines as dirt.

A useful standard: normalized content should match what the user sees, not the internal representation of a layout engine.

DeepSeek Harness: Three things hosts must not touch

All three are display polish and do not belong in the submit path. (source) Comparison:

ActionSounds reasonableActual problem
Merge consecutive spacesTidier contentRewrites code and layout
Convert full-width to half-widthUniform punctuationChanges the user's text
Append missing periodsComplete sentencesAdds content from nothing

What they share: the service cannot tell the original from the optimized result. Once written into a snapshot, the original cannot be restored.

If a product wants cleaner presentation, do it in the render layer rather than editing submitted content.

DeepSeek Harness: The boundary table

One boundary, three roles; follow the table. (source) Boundary:

ContentHostprepare
Mention markersKeepRemove
User bodyNormalize into content blocksCarry as-is
Referenced session contentDo not touchPreserve by bytes

This table settles most disputes: the host touches only its own input, and the service touches only markers and snapshots.

The telltale sign of a violation is string replacement over referenced content inside host code.

DeepSeek Harness: Testing the scope of differences

Four cases keep differences within the expected range. Steps:

  1. A message with consecutive spaces keeps the same count before and after referencing;
  2. A message with CRLF keeps its line endings;
  3. A message with full-width punctuation keeps that punctuation;
  4. A message with a mention loses the marker while the body stays complete.

Cases 1 and 2 target the most common "cleanup rewrites", and case 4 confirms token removal did not eat body text.

Four passes mean normalization affected input shape only.

If normalization fails, reject the submit rather than forcing the raw string into content and asking prepare to parse a reference it cannot recognize.

With the boundary clear, budgeting is next. Read the DSH plugin reference budget and 64 KiB fallback; to see which processing rewrites content, read DSH plugin byte preservation; 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, why does referenced content differ from the source conversation?

Look at host preprocessing first in a DSH plugin reference. If a host merges spaces or normalizes line endings before submit, the snapshot differs even though DSH plugin never rewrote anything.

For DSH plugin, should a host delete mention markers before calling prepare?

No, token removal is DSH plugin prepare's job. Deleting markers early means prepare cannot distinguish body text from reference markers and may treat the content differently.

With DSH plugin, is converting full-width punctuation to half-width part of normalization?

No, that changes the user's original text and violates DSH plugin byte preservation. DSH plugin's byte preservation treats it as a rewrite, not cleanup, even if the result looks tidier.

In DSH plugin, what if normalization fails?

Reject the submit in DSH plugin instead of passing the raw string into content. DSH plugin expects normalized readable blocks, and a host-side failure should not become a parsing problem downstream.

Related Terms

input normalization
Input normalization converts editor content into readable content blocks and is a host responsibility.— DeepSeek Harness reference - Session references
token removal
Token removal deletes host mention markers from the body during prepare.— session-reference/src/index.ts
snapshot preservation
Snapshot preservation carries referenced content byte-for-byte rather than by display needs.— DeepSeek Harness reference - Session references
boundary table
The boundary table assigns each kind of content to the host or to prepare to prevent overlapping edits.— DeepSeek Harness reference - Session references

Sources