-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
Description
When using Qwen/Qwen3-235B-A22B-Instruct-2507
by DeepInfra , I hit this error:
"Invalid response from LLM call - None or empty."
The root cause is that LLMs hosted on DeepInfra respond with an empty message when the input messages exceed the model’s context window.
Agent executor doesn’t proactively check message length before calling the model—it only handles it after an exception is thrown
crewAI/src/crewai/agents/crew_agent_executor.py
Lines 240 to 246 in 610c1f7
except Exception as e: | |
if e.__class__.__module__.startswith("litellm"): | |
# Do not retry on litellm errors | |
raise e | |
if is_context_length_exceeded(e): | |
handle_context_length( | |
respect_context_window=self.respect_context_window, |
This is problematic because different providers handle overflows differently—some return structured errors, others fail silently.
Related to #2990
Steps to Reproduce
- Create an agent with llm=
Qwen/Qwen3-235B-A22B-Instruct-2507
by DeepInfra - Give it a very long input of >40K characters
- Kickoff the crew
Expected behavior
It should summarize the messages prior to calling the LLM
Screenshots/Code snippets
None
Operating System
Ubuntu 20.04
Python Version
3.10
crewAI Version
0.177.0
crewAI Tools Version
0.69.0
Virtual Environment
Venv
Evidence
File "/home/phuihock/github/fxml/.venv/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 153, in _invoke_loop
answer = get_llm_response(
^^^^^^^^^^^^^^^^^
File "/home/phuihock/github/fxml/.venv/lib/python3.11/site-packages/crewai/utilities/agent_utils.py", line 167, in get_llm_response
raise ValueError("Invalid response from LLM call - None or empty.")
Possible Solution
I suggest handling message length earlier in the flow (call handle_context_length
right before get_llm_response
crewAI/src/crewai/agents/crew_agent_executor.py
Lines 187 to 195 in 610c1f7
enforce_rpm_limit(self.request_within_rpm_limit) | |
answer = get_llm_response( | |
llm=self.llm, | |
messages=self.messages, | |
callbacks=self.callbacks, | |
printer=self._printer, | |
from_task=self.task, | |
) |
Additional context
None