{
  "id": "llm/function-call-argument-truncation",
  "signature": "openai.BadRequestError: function_call arguments must be valid JSON - truncated input detected",
  "signature_zh": "openai.BadRequestError: function_call 参数必须是有效 JSON - 检测到输入被截断",
  "regex": "function_call arguments must be valid JSON - truncated",
  "domain": "llm",
  "category": "input_error",
  "subcategory": null,
  "root_cause": "When using function calling, the LLM generates argument JSON that exceeds the model's context window, causing it to truncate mid-JSON, resulting in malformed arguments.",
  "root_cause_type": "generic",
  "root_cause_zh": "使用函数调用时，LLM 生成的参数 JSON 超过了模型的上下文窗口，导致其在 JSON 中间被截断，产生格式错误的参数。",
  "versions": [
    {
      "version": "openai==1.14.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "openai==1.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gpt-4-0125-preview",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gpt-3.5-turbo-0125",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The issue is context window exhaustion, not response token limit; max_tokens only caps the output length, not the input.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The truncation is deterministic given the same input; retrying won't change the behavior.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Reduce the size of the function description or parameters in the function schema to fit within the context window.",
      "success_rate": 0.8,
      "how": "Reduce the size of the function description or parameters in the function schema to fit within the context window.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Split the function call into multiple smaller calls, each with fewer arguments.",
      "success_rate": 0.85,
      "how": "Split the function call into multiple smaller calls, each with fewer arguments.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a model with a larger context window (e.g., gpt-4-32k or gpt-4-turbo) for complex function calls.",
      "success_rate": 0.9,
      "how": "Use a model with a larger context window (e.g., gpt-4-32k or gpt-4-turbo) for complex function calls.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "减小函数描述或参数的大小，使其适应上下文窗口。",
    "将函数调用拆分为多个较小的调用，每个调用使用更少的参数。",
    "使用具有更大上下文窗口的模型（例如 gpt-4-32k 或 gpt-4-turbo）进行复杂函数调用。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://platform.openai.com/docs/guides/function-calling",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-02-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}