Repository navigation
Description
Bug Description
stripHallucinationsFromString() is applied to every completed tool part's state.output as well as to text parts (dist/index.js, stripHallucinations()). Two of the regexes used there delete everything between a <dcp...> opener and a </dcp...> closer:
var DCP_PAIRED_TAG_REGEX = /<dcp[^>]*>[\s\S]*?<\/dcp[^>]*>/gi;
var DCP_UNPAIRED_TAG_REGEX = /<\/?dcp[^>]*>/gi;Because this runs on tool output, any tool result that legitimately contains such a block is silently truncated before the model sees it. That includes reading this plugin's own source and prompt files, its docs, or any third-party file that happens to quote a reminder block. The model has no way to know that content was removed; it just sees a shorter string.
Concrete case: DCP's own default prompts (lib/prompts/turn-nudge.ts, iteration-nudge.ts, context-limit-nudge.ts, system.ts) are wrapped in the reminder tags. read on node_modules/@tarquinen/opencode-dcp/lib/prompts/turn-nudge.ts returns only lines 1 and 10 (the `export const ... = `` line and the closing backtick). Every line of actual instruction text is gone.
Expected Behavior
- Tool output should not be rewritten. Either restrict
stripHallucinationsto text parts, or replace matched blocks with a visible marker (for example[dcp reminder removed]) instead of deleting their content, so the model can tell that something was elided. - If stripping tool parts has to stay, it should not delete content the model has not seen yet: it turns legitimate files into empty strings and makes pasted user content disappear (see below).
How to see it
- DCP 3.2.0, OpenCode V2, default settings,
idFormat: xml. - Write a file
/tmp/t.txtcontainingAAA, a blank line, an opening<dcp-system-reminder>tag, the lineHELLO-INSIDE, the matching closing tag, a blank line, andZZZ. - Ask the agent to
cat /tmp/t.txt. The tool result delivered to the model is onlyAAAandZZZ;HELLO-INSIDEand both tags are gone. - Same with
readonnode_modules/@tarquinen/opencode-dcp/lib/prompts/turn-nudge.ts: only the first and last line come back. - User messages take the same path: pasting a reminder block into the prompt arrives at the model as an empty message.
This is deterministic, unlike the intermittent cases in #642 / #632, which are about tags the model writes into its reply.
My guess (not confirmed)
stripHallucinations() was written for text the model produced — it also removes hallucinated mN</parameter> and <dcp-message-id>...</dcp-message-id> suffixes. Applying it to part.state.output extends a text-hygiene step to content the model never generated, so it can only produce false positives there.
Debug Context Logs
No DCP debug log captured; the reproduction above is deterministic and needs none. The stripped result is observable directly in the tool result the model receives.
DCP Version
3.2.0
Opencode Version
v2.0.29
Model
DeepSeek Flash (deepseek-flash)
Additional Context
- Also observed: the unpaired-tag regex leaves stray characters behind when a suffix is stripped by
INJECTED_MESSAGE_ID_SUFFIX_REGEX/HALLUCINATED_PARAMETER_SUFFIX_REGEX, which shows up as a lone"at the end of a reply. Separate from the deletion issue, but caused by the same function. - Workaround in use locally: none for tool output; there is no config switch to disable this pass, and
autoUpdatemeans a local patch todist/index.jswould be overwritten. - Definition of done: reading a file that contains a
<dcp-*>block returns that file's full contents.
Activity
fix: stop stripping <dcp-*> blocks from tool output and user text (Ta…
Tarquinen commentedon Nov 16, 2026
Fixed in #680 (merged into dev). It will ship in the next release.