fix(llm): handle LiteLLM supports_response_schema introspection failure gracefully (#6412)#6604
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesProvider capability validation
Sequence Diagram(s)sequenceDiagram
participant LLM
participant LiteLLM
participant Logger
LLM->>LLM: Check static provider capabilities
LLM->>LiteLLM: Inspect response-schema support when required
LiteLLM-->>LLM: Return support status or raise an exception
LLM->>Logger: Log unsupported reasoning_effort or introspection failure
LLM-->>LLM: Raise ValueError only for confirmed unsupported response_format
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/crewai/tests/test_llm.py`:
- Around line 1205-1217: Update
test_validate_call_params_skips_check_when_no_response_format so it uses only
parameters that require no validation, rather than reasoning_effort. Add a
separate test covering reasoning_effort with supported and unsupported
model/provider capabilities, verifying the expected fallback behavior while
preserving response_format validation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 33b040d2-b6ff-43b2-8fc9-0acc0e85c7c6
📒 Files selected for processing (2)
lib/crewai/src/crewai/llm.pylib/crewai/tests/test_llm.py
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/crewai/src/crewai/llm.py
282e438 to
5781925
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/crewai/tests/test_llm.py`:
- Around line 1185-1196: Update
test_validate_call_params_handles_introspection_error to accept caplog, invoke
_validate_call_params within the existing patched introspection failure, and
assert the DEBUG logs contain “LiteLLM supports_response_schema check failed”
while preserving the no-exception fallback assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 488e39e5-3b1b-46f2-82fc-d182853081e3
📒 Files selected for processing (2)
lib/crewai/src/crewai/llm.pylib/crewai/tests/test_llm.py
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/crewai/src/crewai/llm.py
…allback coverage tests
8ac9f55 to
33a57b8
Compare
Pull Request Description
Description
Closes #6412
This PR resolves an issue in
LLM._validate_call_params()where unhandled LiteLLM introspection failures insupports_response_schema()would cause_validate_call_params()to crash or skip parameter validation.Root Cause
In
crewai/llm.py,_validate_call_params()invokedsupports_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
supports_response_schema()in_validate_call_params(), mirroring the pattern used insupports_function_calling().DEBUGlevel andis_supporteddefaults toTrue(permitting modern models and proxies with custom model names to execute).test_validate_call_params_handles_introspection_error()inlib/crewai/tests/test_llm.py.Testing
test_validate_call_params_handles_introspection_errorpasses.ruff checkandruff format.