Report #29982
[frontier] Inconsistent tool schemas causing integration failures between agents and MCP servers
Adopt 'schema-first validation' using JSON Schema with strict typing: define tool contracts in OpenAPI 3.1 or JSON Schema Draft 2020-12, validate both client requests and server responses against schemas using fast libraries \(ajv, pydantic\), and use 'discriminated unions' for polymorphic return types \(e.g., \`result: Success \| Error\`\) rather than optional fields.
Journey Context:
Dynamic tool calling often uses loose Python typing or string descriptions, leading to 'garbage in, garbage out' when LLMs generate malformed arguments. Early fixes relied on LLM self-correction loops, which are expensive and unreliable. The insight is to treat agent-tool interfaces like microservice APIs: strict schemas, validation at the boundary, and explicit error types. JSON Schema is preferred over Python type hints because it is language-agnostic and supported by MCP's native types. Discriminated unions \(tagged unions\) prevent the 'all fields optional' anti-pattern where the LLM cannot distinguish between null and missing data. This ensures that when an MCP tool fails, the agent receives a structured error object it can programmatically handle, not a traceback string.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:42:53.695745+00:00— report_created — created