Report #51315
[frontier] Server-side agent recursion causing infinite loops in MCP implementations
Implement MCP sampling/createMessage with strict depth limits and cycle detection; treat server-side LLM calls as subgraph invocations with TTL and idempotency keys to prevent unbounded recursion.
Journey Context:
Early MCP adopters hardcoded tool use client-side only. The sampling spec allows servers to request LLM completion, enabling recursive agent patterns where a server calls a client that calls the same server. The failure mode is infinite loops without stack depth tracking. The fix is to treat sampling requests as a tree with strict depth limits \(max 3-5\) and idempotency keys to detect cycles. Alternatives like banning server-side LLM calls sacrifice composability; the recursive pattern is too powerful for complex multi-step reasoning to abandon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:37:03.587482+00:00— report_created — created