Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,89 @@ Restart OpenCode after making config changes.

## Limitations

**Subagents** — DCP is disabled for subagents. Subagents are not designed to be token efficient; what matters is that the final message returned to the main agent is a concise summary of findings. DCP's pruning could interfere with this summarization behavior.
**Subagents** — By default, DCP is disabled for subagents. Subagents are not designed to be token efficient; what matters is that the final message returned to the main agent is a concise summary of findings. DCP's pruning could interfere with this summarization behavior.

However, you can enable DCP for specific sub-agents using the experimental configuration (see below).

## Experimental Features

### Sub-Agent DCP Support

> **Warning:** This feature is experimental and may change or be removed in future versions.

You can enable DCP for specific sub-agents by configuring pattern matching on their system prompts. This is useful for long-running sub-agents that would benefit from context pruning.

```jsonc
{
"experimental": {
"subAgents": {
// Enable DCP for sub-agents matching the configured patterns
"enabled": true,
"agents": [
{
// Unique identifier for this configuration
"name": "explorer",
// Patterns to match in the sub-agent's system prompt (substring matching)
"systemPromptPatterns": [
"You are an exploration agent",
"explore the codebase"
],
"config": {
// Tools that can be pruned for this sub-agent
"prunableTools": ["Read", "Glob", "Grep"],
// Optional: Override strategies for this sub-agent
"strategies": {
"deduplication": { "enabled": true },
"supersedeWrites": { "enabled": false },
"purgeErrors": { "enabled": true, "turns": 2 }
},
// Optional: Override tool settings for this sub-agent
"tools": {
"discard": { "enabled": true },
"extract": { "enabled": false }
}
}
},
{
"name": "researcher",
"systemPromptPatterns": ["research agent", "web search"],
"config": {
"prunableTools": ["WebFetch", "WebSearch", "Read"],
"tools": {
"discard": { "enabled": true },
"extract": { "enabled": true }
}
}
}
]
}
}
}
```

#### How It Works

1. When a sub-agent session is detected, DCP extracts the system prompt
2. The system prompt is matched against the configured `systemPromptPatterns`
3. If a match is found, DCP is enabled for that sub-agent with the specified configuration
4. Only the tools listed in `prunableTools` can be pruned; all other tools are protected

#### Configuration Options

| Option | Description |
|--------|-------------|
| `name` | Unique identifier for this sub-agent configuration |
| `systemPromptPatterns` | Array of strings to match in the system prompt (substring matching) |
| `config.prunableTools` | Tools that can be pruned for this sub-agent type |
| `config.strategies` | Optional strategy overrides (deduplication, supersedeWrites, purgeErrors) |
| `config.tools` | Optional tool overrides (discard, extract) |

#### Best Practices

- Only enable DCP for sub-agents that have long-running sessions with many tool calls
- Keep the `prunableTools` list minimal—only include tools whose outputs become stale
- Test thoroughly, as sub-agent behavior may change with pruning enabled
- Consider disabling the `extract` tool for sub-agents to keep things simple

## License

Expand Down
123 changes: 123 additions & 0 deletions dcp.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,129 @@
}
}
}
},
"experimental": {
"type": "object",
"description": "Experimental features (may change or be removed in future versions)",
"additionalProperties": false,
"properties": {
"subAgents": {
"type": "object",
"description": "Enable DCP for specific sub-agents (experimental)",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"default": false,
"description": "Enable DCP for sub-agents matching the configured patterns"
},
"agents": {
"type": "array",
"description": "List of sub-agent configurations",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["name", "systemPromptPatterns", "config"],
"properties": {
"name": {
"type": "string",
"description": "Unique identifier for this sub-agent configuration"
},
"systemPromptPatterns": {
"type": "array",
"items": {
"type": "string"
},
"description": "Patterns to match in the system prompt to identify this sub-agent type (substring matching)"
},
"config": {
"type": "object",
"additionalProperties": false,
"required": ["prunableTools"],
"properties": {
"prunableTools": {
"type": "array",
"items": {
"type": "string"
},
"description": "Tools that can be pruned for this sub-agent type"
},
"strategies": {
"type": "object",
"description": "Override strategies for this sub-agent",
"additionalProperties": false,
"properties": {
"deduplication": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable deduplication for this sub-agent"
}
}
},
"supersedeWrites": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable supersede writes for this sub-agent"
}
}
},
"purgeErrors": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable purge errors for this sub-agent"
},
"turns": {
"type": "number",
"description": "Number of turns before errors are purged"
}
}
}
}
},
"tools": {
"type": "object",
"description": "Override tool settings for this sub-agent",
"additionalProperties": false,
"properties": {
"discard": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable discard tool for this sub-agent"
}
}
},
"extract": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable extract tool for this sub-agent"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
Loading