Skip to content

fix(llm): handle LiteLLM supports_response_schema introspection failure gracefully (#6412)#6604

Open
Hasnaathussain wants to merge 1 commit into
crewAIInc:mainfrom
Hasnaathussain:fix/6412-provider-capabilities-fallback
Open

fix(llm): handle LiteLLM supports_response_schema introspection failure gracefully (#6412)#6604
Hasnaathussain wants to merge 1 commit into
crewAIInc:mainfrom
Hasnaathussain:fix/6412-provider-capabilities-fallback

Conversation

@Hasnaathussain

Copy link
Copy Markdown

Pull Request Description

Description

Closes #6412

This PR resolves an issue in LLM._validate_call_params() where unhandled LiteLLM introspection failures in supports_response_schema() would cause _validate_call_params() to crash or skip parameter validation.

Root Cause

In crewai/llm.py, _validate_call_params() invoked supports_response_schema() directly without exception handling. If LiteLLM failed to introspect an unmapped/custom model ID or raised an exception, _validate_call_params() crashed unhandled.

Proposed Changes

  1. Added exception handling around supports_response_schema() in _validate_call_params(), mirroring the pattern used in supports_function_calling().
  2. On LiteLLM introspection errors, the failure is logged at DEBUG level and is_supported defaults to True (permitting modern models and proxies with custom model names to execute).
  3. Added unit test test_validate_call_params_handles_introspection_error() in lib/crewai/tests/test_llm.py.

Testing

  • Verified test_validate_call_params_handles_introspection_error passes.
  • Verified linting and formatting with ruff check and ruff format.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ee9c425f-2799-495a-89c1-d28a33a412c0

📥 Commits

Reviewing files that changed from the base of the PR and between ce739e2 and 5c61444.

📒 Files selected for processing (2)
  • lib/crewai/src/crewai/llm.py
  • lib/crewai/tests/test_llm.py

📝 Walkthrough

Walkthrough

_validate_call_params now skips validation without a response format, tolerates LiteLLM schema introspection errors, and raises only for confirmed unsupported combinations. A unit test covers the introspection-error path.

Changes

Response format validation

Layer / File(s) Summary
Guarded response-format validation and regression coverage
lib/crewai/src/crewai/llm.py, lib/crewai/tests/test_llm.py
_validate_call_params handles missing formats and schema-check exceptions, while unsupported models still raise ValueError; a unit test verifies introspection failures do not propagate.

Suggested reviewers: lorenzejay, greysonlalonde

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The change appears to fix the crash, but it doesn't show that get_capabilities fallback or reasoning_effort validation still run as required. Ensure static capability checks run even when LiteLLM introspection fails, and add tests for response_format and reasoning_effort fallback coverage.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the LiteLLM introspection failure fix.
Description check ✅ Passed The description matches the bug fix and added test described in the changes.
Out of Scope Changes check ✅ Passed Only the LLM validation code and a focused unit test were changed, which fits the stated bug fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ProviderCapabilities.get_capabilities() static fallbacks are skipped when LiteLLM introspection fails

1 participant