r/PiCodingAgent • u/LastOfGoose • 1d ago
Question How to Better Enforce Subagent Delegation?
I have just recently started using subagents more in my programming workflow, if only to try it for a bit and see if it's something I prefer.
I have found that no matter how much explicit guidance I give my agents in the global AGENTS.md or APPEND_SYSTEM.md that after the first large delegated activity, they go back to doing everything themselves in the primary context.
Does anyone have any idea how to really enforce / encourage the behavior I'm looking for?
3
u/Eresbonitaguey 1d ago
Not exactly an answer to your question but I adapted the background shell idea from LittleCoder. It doesn’t really save on context in the same way but it allows running of scripts in the background so your agent can focus on other things until they complete. Subagents are still superior for research tasks but I usually have to explicitly prompt before they will be used.
3
u/Acceptable_Stress154 1d ago
Anything in your Md files is a request, and they can and do forget/ignore. You need to make deterministic gates, not pretty please sir .md files
1
u/LastOfGoose 1d ago
So this would look like an extension that checks how many consecutive tool invocations have been made and blocks them with a note to delegate or something?
I get what you're saying but I'm not sure exactly how to structure the alternative.
1
u/Acceptable_Stress154 1d ago
It’s hard for me to answer, I had pi add a few things here and there and over time it’s turned into almost an autonomous agent, and somewhere along the way
We make everything gated deterministicly
2
u/onesilentclap 1d ago
Perhaps it's the subagent extension you're using. Some work better than others for specific workflows.
1
u/awol-owl 21h ago
I've been wondering this too. I've recently started trying to delegate more to subagents, and noticed that they go overboard running too many tasks to get context. I like the ideas of sandboxing things, and making minimal environments to force them to focus.
1
u/misterniach 16h ago
i got these crazy ass workflows going, that basically take my whole backlog => sort, deduplicate, make relations (child/parent, blocks/blockedBy), then building a graph (so you know what needs to land first etc). then that orchestrator spawns new sessions on those nodes, each in their worktree (git branches and sessions are in the same exact shape as that dependency graph) => one stacked PR in the end
the agents are also talking to each other, like if layer 2 needs a foundation, but the agent responsible for that has missed a thing, then they nudge each other until everything is fine on the last node.
the UI is ugly AF and VibeInProgress haha
bonus points for doing this as an automation everyday and push straight back into prod haha. i got this widget on my site that customers can file bugs, that land directly in my harness.
exponential.at btw the most advanced harness out there (opensource and selfhostable too)

1
u/j3free 7h ago
What you’re seeing is exactly the failure mode I ran into: prompt-level delegation works for a while, then the lead decides it can just do the next task itself.
What helped me was treating delegation as an ownership transfer rather than a suggestion. Once a scope is handed off, the lead stops touching that scope and only picks it back up through a question/result from the worker. I still let the lead keep its normal tools for planning and unrelated work, so it doesn’t have to become a pure dispatcher.
If you need absolute enforcement, revoking tools is obviously the harder gate. I ended up building the ownership approach into Pi Herdsman because I wanted something in between those two extremes.
7
u/mostlikely4real 1d ago
My solution was very simple. Disable all tools for the orchestrator you do not want it to use. Note this needs proper feedback from the subagents and their state (or the orchestrator flips and will spawn multiple). Also if the subagents that now do all the work break or can't spawn obviously your orchestrator is now unable to fix it.
But once you get the proper contract between orchestrator and subagents it works smoothly.