DSH plugin byte preservation: four silent rewrites to stop
Referenced content differing from the original by one space usually means someone in the chain did a friendly cleanup: DSH plugin's byte preservation allows only mention token removal, and everything else is carried as-is. The more harmless a normalization looks, the more likely it leaves a trace here.
DeepSeek Harness: Why one character differs
The differences hide in invisible whitespace. (source) Three frequent scenes:
source: line one\r\nline two reference: line one\nline two
source: a = 1 reference: a = 1
source: 你好,世界。 reference: 你好,世界.
Users do not compare bytes; models do. A changed line ending can alter code block parsing, and a changed punctuation width can alter retrieval matches.
What these share: the text "looks the same" but is not the same bytes.
DeepSeek Harness: The byte preservation contract
It is a content contract, not a performance tweak. (source) Three layers of meaning:
- Referenced content is carried as a snapshot, not reflowed for display;
- The only permitted modification is removing host mention tokens;
- Compression and truncation are explicit behaviors that must record facts.
Layer two draws the responsibility line: prepare subtracts, the host does not beautify.
Layer three separates "omitted" from "rewritten": the former is recorded, the latter is not.
DeepSeek Harness: Four rewrites that change content
Four actions cover most quiet rewrites. (source) Comparison:
| Processing | Apparent purpose | Actual effect |
|---|---|---|
| Merge consecutive spaces | Tidier layout | Breaks code indentation and alignment |
| Normalize line endings | Cross-platform consistency | Changes code blocks and paragraphs |
| Convert full-width punctuation | Uniform punctuation | Breaks matching against the original |
| Append missing punctuation | Complete sentences | Adds content from nothing |
The third is the most invisible: after Chinese punctuation becomes ASCII, searching the original text may fail.
The fourth is worse in kind: it is not a rewrite but generation.
DeepSeek Harness: Truncation, compaction, preservation
All three change what arrives, but only one is a rewrite. (source) Comparison:
| Behavior | Changes the original | Leaves a record |
|---|---|---|
| Byte preservation | No | Not applicable |
| Truncation | Yes, removes content | Records omitted fields and truncated |
| Source compaction | Yes, restructures content | Records compacted |
Truncation and compaction are explicit contracts that callers can see; rewrites leave no trace, which makes them hardest to diagnose.
The test is simple: if a difference has no field explaining it, it is a rewrite.
DeepSeek Harness: What hosts should do instead
Three actions keep processing on input shape. (source) Practices:
- Convert editor structure into content blocks without touching the text;
- Keep only necessary invalid-character cleanup and record its scope;
- Put display polish in the render layer and never write it back to submitted content.
The third is fundamental: once polish is written back, every later stage can only see the polished version.
If a product truly wants uniform punctuation, ship it as an explicit feature users can choose, not as an invisible default.
One more easily missed point: logs and telemetry should not truncate or redact in ways that change content, or debugging shows something other than what reached the model.
DeepSeek Harness: A three-step byte comparison
Three steps locate the source of a difference. (source) Steps:
- Take content containing consecutive spaces, CRLF, and full-width punctuation;
- Bypass host preprocessing, call prepare directly, and record the result;
- Run prepare through the full host chain and diff the two results byte by byte.
A difference at step 2 points at the service side (rare); a difference only at step 3 points at the host.
Do not judge with an editor's "looks the same"; use a diff or a hash.
If the two results differ only by mention tokens, the host chain did not rewrite content; any other difference deserves tracing to a specific stage.
With the difference located, the next topic is normalization boundaries. Read what hosts normalize before referencing; to see how truncation is recorded, read DSH plugin truncation fields; for the wider picture, read how DSH plugin implements session references.
Sources: DeepSeek Harness reference - Session references, session-reference/src/types.ts
FAQ
Someone in the chain tidied it, which DSH plugin byte preservation forbids. DSH plugin byte preservation allows only removing mention tokens; treating whitespace as cleanup changes the referenced snapshot.
DSH plugin byte preservation constrains how referenced content is carried. DSH plugin permits removing host mention tokens but forbids rewriting the body for display, such as merging spaces or converting punctuation.
It depends on scope in DSH plugin. The rule targets content rewriting; removing genuinely invalid characters that would break parsing is input legality handling, but tabs and newlines are not dirt.
Call DSH plugin prepare directly with the same content, bypassing host preprocessing, and diff the two results byte by byte. DSH plugin's output should differ only by mention tokens.
Related Terms
- byte preservation
- Byte preservation requires carrying referenced content as-is except for removing mention markers, never reshaping it for display.— DeepSeek Harness reference - Session references
- content rewrite
- A content rewrite changes spaces, line endings, punctuation, or encoding even when the result looks tidier.— DeepSeek Harness reference - Session references
- token removal
- Token removal is the only permitted modification: prepare deletes host mention markers from the body.— session-reference/src/types.ts
- byte diff
- A byte diff compares processed and original content byte by byte to locate exactly where a rewrite happened.— DeepSeek Harness reference - Session references
Sources
- DeepSeek Harness reference - Session references· deepseek-ai
- session-reference/src/types.ts· deepseek-ai