Skip to content

chore: add <protect> tags to slash command files for DCP context preservation #221

Closed

Description

@jflowers

Problem

OpenCode's DCP (Dynamic Context Pruning) plugin compresses slash command content during long sessions. Unlike skills (which are delivered via the skill tool and are protected by DCP's default protectedTools), slash commands are injected as user messages in the conversation — making them fully eligible for compression.

This was confirmed by investigating the OpenCode source code:

  • Skills: tool/skill.ts — delivered as tool_use/tool_result pairs, protected by DCP's default protectedTools list
  • Commands: session/prompt.ts:1356-1481 → createUserMessage() — delivered as role: "user" messages, no DCP protection

For long-running pipeline commands, DCP can compress away the command instructions mid-execution, causing the agent to lose its operating instructions.

Solution

Add <protect>...</protect> tags around critical sections of each slash command file. When DCP's compress.protectTags config is enabled, content wrapped in these tags is preserved verbatim during compression rather than being summarized away.

What to wrap

Not every line needs protection. Focus <protect> tags on:

  1. Guardrails and safety rules — sections that prevent destructive actions
  2. Execution checklists and step definitions — the structural backbone
  3. Exit conditions and resume instructions — critical for pipeline resumability
  4. Session-resume guards — instructions about not trusting compressed context

Verbose explanations, examples, and formatting guidance can remain unprotected — DCP's compression summaries handle those adequately.

Prerequisite

Users must enable protectTags in their DCP config (~/.config/opencode/dcp.jsonc):

{
  "compress": {
    "protectTags": true
  }
}

Source command files in this repo

The source templates live in internal/scaffold/assets/commands/ and are scaffolded into projects via gaze init:

internal/scaffold/assets/commands/gaze-fix.md
internal/scaffold/assets/commands/gaze.md
internal/scaffold/assets/commands/speckit.testreview.md

Priority

gaze-fix.md is the highest priority — it runs a multi-step fix pipeline that can span many turns. gaze.md and speckit.testreview.md are shorter but still benefit from protection on their guardrails sections.

Metadata

Metadata

Assignees

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions