-
Notifications
You must be signed in to change notification settings - Fork 30
feat(experimental): add DCP support for sub-agents #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(experimental): add DCP support for sub-agents #298
Conversation
Add experimental configuration to enable DCP for specific sub-agents based on system prompt pattern matching. Key changes: - Add experimental.subAgents configuration section - Allow per-sub-agent configuration of prunable tools - Support strategy and tool overrides per sub-agent - Detect sub-agent type from system prompt patterns - Apply DCP only when enabled and patterns match This feature allows users to selectively enable context pruning for long-running sub-agents that would benefit from reduced context size.
|
The main issue I have with allowing DCP into subagents is that if any DCP tools trigger at the end of the models response (which they love to do), it will override the information the subagents sends back to it's parent agent, making the entire subagent session useless and confusing the parent session. This happens because subagents send only the very last message back up to the parent session. As far as I can tell, your code doesn't handle this core issue. What do you think? |
|
Interesting, I'm sure we can find a workaround for that. |
|
Yea there's no tool or anything, it's a pretty simple system. As far as I know, subagents just send the text part from the last assistant message before going idle up to the parent session. |
|
May be the correct implémentation would be to change current behaviour of DCP, instead of prompting prunable-tools after each message we could do it before each message. That would prevent any tool to be called after the completion message, it will also correct the current behaviour that we have sometimes in main agent after the completion message -> DCP -> "...The message is a context management remember..." (+ Will avoid an extra completion request (with cache invalidation) at the end of each session=bucks saved) It might also be possible to just prompt thè sub agent (in context info) to avoid use of extract/discord for the final completion ? Because the second option is to enforce a completion tool at subagents level in Opencode but less performing models can have troubles doing that, even with auto reminder... What do you think ? |
|
pruneable-tools is just a list of tools the LLM has used earlier in the session that are available for pruning, it looks something like:
The model uses this list as reference material for the extract/discard tools, so it can pick what to prune. Changing where you inject that list will not prevent the model from using extract/discard tools. It also wouldn't affect any of the other issues you mentioned, the second of which was fixed recently when the injection system moved to assistant role messages. Prompting the subagent is not a good enough solution, models ignore prompts all the time and there's too big a risk here as it could ruin all the information in your parent session. Honestly i'm not really sure how to solve this, let me know if you have any other ideas |
|
Hey @Tarquinen! 👋 You were right. When the LLM calls I think the best we can do is :
If agressive prompting turns out to be unreliable in practice, the real fix would be on OpenCode's side: add a Makes sense to keep this under experimental since reliability really depends on model prompt adherence. Also worth noting that in some workflows the sub-agent summary isn't critical anyway, so having this as an option lets people choose based on their actual use case. |
Add experimental configuration to enable DCP for specific sub-agents based on system prompt pattern matching.
Key changes:
This feature allows users to selectively enable context pruning for long-running sub-agents that would benefit from reduced context size.
Code not tried yet but DCP for sub agents would be a really useful features, sometimes we don't really care if the sub agent resume is perfect and we need the precious extra context DCP offers. Can be disabled by default but should be something configurable, even if experimental with warning.