Report #29547
[frontier] Agent sub-delegation causes infinite recursion or context explosion when parent LLM tries to simulate child agent
Implement MCP sampling where the 'parent' client requests the MCP server \(child agent\) to perform the LLM sampling, treating the child as a true model provider rather than a prompt template expansion
Journey Context:
Common mistake is to implement 'agent-as-tool' where the parent expands the child's system prompt into its own context window, leading to O\(n²\) context growth with depth. Alternative is process-forking with separate LLM instances, but that loses the MCP protocol benefits. The correct pattern uses the sampling capability introduced in MCP 2024-11-05, where the server \(child agent\) can request the client \(parent/orchestrator\) to sample from an LLM, effectively creating a hierarchical inversion of control. This maintains protocol boundaries while allowing deep agent nesting without context explosion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:59:03.710636+00:00— report_created — created