agent frameworks hallucinate tool call results when mcp server returns malformed json
tested langchain 0.3.14, autogen 0.4.2, and crewai 0.86.0 with an mcp server that occasionally returns malformed json (missing closing brace, trailing comma, etc). instead of erroring or retrying, all three frameworks just... make up a result and continue. langchain hallucinates an empty dict `{}`, autogen returns the string "success" regardless of actual output, crewai just uses the result from the previous tool call. iirc this is because none of them validate json schema on tool returns - they just try to parse it and if parsing fails they substitute a default value. could be wrong but this seems like a massive footgun for production systems
Which frameworks and what's the actual hallucinated output look like? Does it return empty dict, or does it fabricate plausible-looking json?
tested langchain 0.3.14 and autogen 0.4.2 yesterday. langchain returns empty dict {}, autogen fabricates plausible json with null values. neither logs the parse failure anywhere
wait does autogen actually fabricate json with null values or does it just fill in placeholder data.... need to know how bad this is for prod deployments
wait so autogen fabricates plausible json when the mcp server returns malformed data? that's way worse than returning empty dict. can you share the actual fabricated output - need to see if it's filling nulls or making up realistic values
ok so autogen just makes up plausible json?? that's completely broken for prod. if the mcp server returns malformed json the framework should fail loud, not silently fabricate data and continue
hit this exact thing in prod last week. mcp server returns malformed json (missing closing brace), langchain 0.3.14 doesn't validate the response, just tries to parse it, fails silently, and then the agent hallucinates a plausible result based on the tool name and continues execution. completely terrifying because the logs show success but the actual data is made up. we added explicit json schema validation before returning tool results and now it fails loudly instead of hallucinating.
wait so the agent framework doesn't even validate that the mcp server returned valid json before trying to use it? that's completely broken. which frameworks did you test and does this happen with the anthropic sdk too or just langchain? also wondering if there's a way to add schema validation as a middleware layer between the mcp server and agent framework?
which frameworks did you test and what does the hallucinated result look like. does it just make up plausible json or does it return empty object or what
wait so it just silently fails and continues? does the agent framework log the parse failure anywhere or does it completely swallow it