llamaIndex - ✅(Solved) Fix [Bug] parallel_tool_calls parameter sent to models that don't support it (o1, o3-mini, o4-mini) [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
run-llama/llama_index#20865Fetched 2026-04-08 00:30:34
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
closed ×1commented ×1cross-referenced ×1mentioned ×1

Error Message

BadRequestError: Error code: 400 - {
  'error': {
    'message': "Unsupported parameter: 'parallel_tool_calls' is not supported with this model.",
    'type': 'invalid_request_error',
    'param': 'parallel_tool_calls',
    'code': 'unsupported_parameter'
  }
}

Root Cause

In llama_index/llms/openai/base.py, _prepare_chat_with_tools returns:

if tool_specs:
    kwargs["parallel_tool_calls"] = allow_parallel_tool_calls

This sends parallel_tool_calls (True or False) for all models. Models in O1_MODELS (which already exists in utils.py) reject this parameter entirely.

Fix Action

Fixed

PR fix notes

PR #20866: fix: strip parallel_tool_calls for reasoning models

Description (problem / solution / changelog)

Summary

  • Reasoning models (o1-preview, o1-mini) do not support the parallel_tool_calls parameter in the OpenAI API
  • Added a guard in _prepare_chat_with_tools to only include parallel_tool_calls when the model is not in O1_MODELS
  • Added two unit tests verifying the behavior for both reasoning and non-reasoning models

Test plan

  • test_prepare_chat_with_tools_reasoning_model_omits_parallel_tool_callso1-mini does not send parallel_tool_calls
  • test_prepare_chat_with_tools_non_reasoning_model_includes_parallel_tool_callsgpt-4o sends parallel_tool_calls
  • All existing tests pass

Fixes #20865

🤖 Generated with Claude Code

Changed files

  • llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/base.py (modified, +1/-1)
  • llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml (modified, +1/-1)
  • llama-index-integrations/llms/llama-index-llms-openai/tests/test_openai.py (modified, +36/-0)

Code Example

BadRequestError: Error code: 400 - {
  'error': {
    'message': "Unsupported parameter: 'parallel_tool_calls' is not supported with this model.",
    'type': 'invalid_request_error',
    'param': 'parallel_tool_calls',
    'code': 'unsupported_parameter'
  }
}

---

if tool_specs:
    kwargs["parallel_tool_calls"] = allow_parallel_tool_calls

---

if tool_specs and self.model not in O1_MODELS:
    kwargs["parallel_tool_calls"] = allow_parallel_tool_calls
RAW_BUFFERClick to expand / collapse

Bug Description

_prepare_chat_with_tools in llama-index-llms-openai unconditionally includes parallel_tool_calls in the API request body whenever tools are present, regardless of the model being used. Models like o1, o3-mini, and o4-mini do not support this parameter at all — even passing parallel_tool_calls=False results in a 400 error.

Error

BadRequestError: Error code: 400 - {
  'error': {
    'message': "Unsupported parameter: 'parallel_tool_calls' is not supported with this model.",
    'type': 'invalid_request_error',
    'param': 'parallel_tool_calls',
    'code': 'unsupported_parameter'
  }
}

Root Cause

In llama_index/llms/openai/base.py, _prepare_chat_with_tools returns:

if tool_specs:
    kwargs["parallel_tool_calls"] = allow_parallel_tool_calls

This sends parallel_tool_calls (True or False) for all models. Models in O1_MODELS (which already exists in utils.py) reject this parameter entirely.

Suggested Fix

Skip parallel_tool_calls for models in O1_MODELS, similar to how max_tokens and reasoning_effort are already handled:

if tool_specs and self.model not in O1_MODELS:
    kwargs["parallel_tool_calls"] = allow_parallel_tool_calls

Version

  • llama-index-llms-openai: tested on 0.5.6; also confirmed unfixed on latest 0.6.25 (by reading source)

extent analysis

Fix Plan

Step 1: Update _prepare_chat_with_tools in base.py

# llama_index/llms/openai/base.py
import utils

def _prepare_chat_with_tools(self, tool_specs, allow_parallel_tool_calls):
    kwargs = {}
    if tool_specs and self.model not in utils.O1_MODELS:
        kwargs["parallel_tool_calls"] = allow_parallel_tool_calls
    # ... rest of the function remains the same ...
    return kwargs

Step 2: Update utils.py (if necessary)

If O1_MODELS is not defined in utils.py, add it:

# llama_index/utils.py
O1_MODELS = ['o1', 'o3-mini', 'o4-mini']

Verification

  1. Run the affected API endpoint with tools present and a model from O1_MODELS.
  2. Verify that the parallel_tool_calls parameter is not included in the API request body.
  3. Run the API endpoint with tools present and a model not in O1_MODELS.
  4. Verify that the parallel_tool_calls parameter is included in the API request body with the correct value.

Extra Tips

  • Make sure to test the fix thoroughly with different models and tool configurations.
  • Consider adding a test case to the llama_index test suite to ensure this fix remains correct in the future.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING