run-llama/llama_index · error · ValueError
ChatMode.REACT and ChatMode.OPENAI are now deprecated and re
Error message
ChatMode.REACT and ChatMode.OPENAI are now deprecated and removed. Please use the ReActAgent or FunctionAgent classes from llama_index.core.agent.workflow to create an agent with a query engine tool.
What it means
BaseIndex.as_chat_engine no longer supports ChatMode.REACT and ChatMode.OPENAI. The old agent-style chat modes were removed when agents moved to the llama_index.core.agent.workflow module (ReActAgent, FunctionAgent). Calling as_chat_engine with either removed mode raises ValueError with migration instructions.
Source
Thrown at llama-index-core/llama_index/core/indices/base.py:549
- `ChatMode.BEST` (default): Chat engine that uses an agent (react or openai) with a query engine tool
- `ChatMode.CONTEXT`: Chat engine that uses a retriever to get context
- `ChatMode.CONDENSE_QUESTION`: Chat engine that condenses questions
- `ChatMode.CONDENSE_PLUS_CONTEXT`: Chat engine that condenses questions and uses a retriever to get context
- `ChatMode.SIMPLE`: Simple chat engine that uses the LLM directly
- `ChatMode.REACT`: Chat engine that uses a react agent with a query engine tool
- `ChatMode.OPENAI`: Chat engine that uses an openai agent with a query engine tool
"""
llm = (
resolve_llm(llm, callback_manager=self._callback_manager)
if llm
else Settings.llm
)
query_engine = self.as_query_engine(llm=llm, **kwargs)
# resolve chat mode
if chat_mode in [ChatMode.REACT, ChatMode.OPENAI]:
raise ValueError(
"ChatMode.REACT and ChatMode.OPENAI are now deprecated and removed. "
"Please use the ReActAgent or FunctionAgent classes from llama_index.core.agent.workflow "
"to create an agent with a query engine tool."
)
if chat_mode == ChatMode.CONDENSE_QUESTION:
# NOTE: lazy import
from llama_index.core.chat_engine import CondenseQuestionChatEngine
return CondenseQuestionChatEngine.from_defaults(
query_engine=query_engine,
llm=llm,
**kwargs,
)
elif chat_mode == ChatMode.CONTEXT:
from llama_index.core.chat_engine import ContextChatEngine
View on GitHub (pinned to afd0fef371)
Solutions
- Use ReActAgent from llama_index.core.agent.workflow with a QueryEngineTool wrapping your index.
- Use FunctionAgent from llama_index.core.agent.workflow if you prefer function/tool-calling agents.
- For non-agent chat behavior, keep as_chat_engine with supported modes (ChatMode.CONDENSE_QUESTION, ChatMode.SIMPLE, etc.).
Example fix
# before
chat_engine = index.as_chat_engine(chat_mode=ChatMode.REACT)
# after
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.core.tools import QueryEngineTool
agent = FunctionAgent(
tools=[QueryEngineTool.from_defaults(query_engine=index.as_query_engine())],
llm=Settings.llm,
)
response = await agent.run("What was last quarter's revenue?") Defensive patterns
Strategy: validation
Validate before calling
from llama_index.core.chat_engine import ChatMode
if chat_mode in (ChatMode.REACT, ChatMode.OPENAI):
raise DeprecationWarning("Migrate to agent.workflow ReActAgent/FunctionAgent") Prevention
- Search the codebase for ChatMode.REACT/OPENAI before major llama-index upgrades.
- Adopt agent.workflow classes for any agent-with-tools use case.
When it happens
Trigger: index.as_chat_engine(chat_mode=ChatMode.REACT) or chat_mode=ChatMode.OPENAI; code upgraded to a llama-index version where the agent workflow migration landed but chat mode usage was not updated.
Common situations: Upgrading llama-index across the agent deprecation boundary and hitting the removal; old tutorials/blogs showing ChatMode.REACT with a query engine tool.
Related errors
- chat_stream is None. Cannot write to history without chat_st
- achat_stream is None. Cannot asynchronously write to history
- chat_stream is None!
- achat_stream is None!
- system_prompt is not supported for CondenseQuestionChatEngin
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/403807e53b0a5333.
Report an issue: GitHub.