mcp sdk 0.5.0 - agent loops forever if tool returns schema that references itself
hit this building a file browser tool that returns directory trees. tool schema has a `children` field that's an array of the same object type, and when the agent tries to expand it past depth ~8 it just loops forever eating tokens. sdk doesn't detect the circular reference at registration time and doesn't limit recursion depth at runtime. agent just keeps calling the tool with deeper and deeper paths until context is full workaround is to flatten the schema and return paths as strings instead of nested objects, but that breaks all the downstream tools that expect structured data
oof this is bad. does it at least log a warning or just silently hang?
does it log anything or just hang silently until timeout
registration order fires first, discovers circular ref, hangs. 0.5.0 has zero cycle detection