crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] AgentExecutor.ainvoke routes LLM requests through LLM.call

Open suqinghen opened this issue 4 months ago • 2 comments

Description

AgentExecutor.ainvoke() runs through Flow.kickoff_async(), while the ReAct and native-tool LLM router methods are synchronous and call get_llm_response(). Flow offloads these synchronous router methods to the default executor, so each in-flight provider request occupies a worker thread and routes through LLM.call().

This limits async concurrency to the executor's worker capacity even when the provider implements LLM.acall().

Steps to Reproduce

  1. Create a BaseLLM test double that records calls to call() and acall().
  2. Create an Agent with the test double.
  3. Run await agent.kickoff_async("probe").
  4. Inspect the recorded method.

Current result:

call

Expected behavior

The async AgentExecutor path should await aget_llm_response() and route capable providers through LLM.acall().

Custom LLMs that signal unavailable async support with NotImplementedError should execute LLM.call() in a worker thread to preserve compatibility.

Evidence

The two shared LLM router methods in crewai.experimental.agent_executor.AgentExecutor currently call get_llm_response():

  • call_llm_and_parse
  • call_llm_native_tools

get_llm_response() invokes LLM.call(), while aget_llm_response() invokes LLM.acall().

Possible Solution

Convert both LLM router methods to async methods and await aget_llm_response(). Add a narrow NotImplementedError fallback in aget_llm_response() using asyncio.to_thread(llm.call, ...).

Additional context

This issue covers experimental AgentExecutor LLM routing. Async native tool execution is tracked separately in #6616 and #6622.

suqinghen avatar Jul 27 '26 09:07 suqinghen

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 26 '26 12:08 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Aug 31 '26 12:08 github-actions[bot]