llm runtime_error ai_generated true

JSONDecodeError: Expecting property name at position N

ID: llm/tool-calling-json-parse

Also available as: JSON · Markdown
78%Fix Rate
80%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
any active

Root Cause

LLM generated malformed JSON in tool/function call arguments.

generic

Workarounds

  1. 88% success Use structured output / JSON mode if available
    response_format={"type":"json_object"} or tool_choice="required"
  2. 80% success Implement JSON repair before parsing
    Use json-repair library or regex fixups for common issues like trailing commas

Dead Ends

Common approaches that don't work:

  1. Parse with eval() instead of json.loads 90% fail

    eval is a security risk and still fails on malformed output.

  2. Retry with same prompt hoping for valid JSON 60% fail

    Without guidance, LLM may produce same malformed output.