# openai.BadRequestError: function_call arguments must be valid JSON - truncated input detected

- **ID:** `llm/function-call-argument-truncation`
- **Domain:** llm
- **Category:** input_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| openai==1.14.0 | active | — | — |
| openai==1.20.0 | active | — | — |
| gpt-4-0125-preview | active | — | — |
| gpt-3.5-turbo-0125 | active | — | — |

## Workarounds

1. **Reduce the size of the function description or parameters in the function schema to fit within the context window.** (80% success)
   ```
   Reduce the size of the function description or parameters in the function schema to fit within the context window.
   ```
2. **Split the function call into multiple smaller calls, each with fewer arguments.** (85% success)
   ```
   Split the function call into multiple smaller calls, each with fewer arguments.
   ```
3. **Use a model with a larger context window (e.g., gpt-4-32k or gpt-4-turbo) for complex function calls.** (90% success)
   ```
   Use a model with a larger context window (e.g., gpt-4-32k or gpt-4-turbo) for complex function calls.
   ```

## Dead Ends

- **** — The issue is context window exhaustion, not response token limit; max_tokens only caps the output length, not the input. (70% fail)
- **** — The truncation is deterministic given the same input; retrying won't change the behavior. (95% fail)
