{"record":{"id":"403807e53b0a5333","repo":"run-llama/llama_index","slug":"chatmode-react-and-chatmode-openai-are-now-depreca","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/indices/base.py","lineNumber":549,"sourceCode":"            - `ChatMode.BEST` (default): Chat engine that uses an agent (react or openai) with a query engine tool\n            - `ChatMode.CONTEXT`: Chat engine that uses a retriever to get context\n            - `ChatMode.CONDENSE_QUESTION`: Chat engine that condenses questions\n            - `ChatMode.CONDENSE_PLUS_CONTEXT`: Chat engine that condenses questions and uses a retriever to get context\n            - `ChatMode.SIMPLE`: Simple chat engine that uses the LLM directly\n            - `ChatMode.REACT`: Chat engine that uses a react agent with a query engine tool\n            - `ChatMode.OPENAI`: Chat engine that uses an openai agent with a query engine tool\n        \"\"\"\n        llm = (\n            resolve_llm(llm, callback_manager=self._callback_manager)\n            if llm\n            else Settings.llm\n        )\n\n        query_engine = self.as_query_engine(llm=llm, **kwargs)\n\n        # resolve chat mode\n        if chat_mode in [ChatMode.REACT, ChatMode.OPENAI]:\n            raise ValueError(\n                \"ChatMode.REACT and ChatMode.OPENAI are now deprecated and removed. \"\n                \"Please use the ReActAgent or FunctionAgent classes from llama_index.core.agent.workflow \"\n                \"to create an agent with a query engine tool.\"\n            )\n\n        if chat_mode == ChatMode.CONDENSE_QUESTION:\n            # NOTE: lazy import\n            from llama_index.core.chat_engine import CondenseQuestionChatEngine\n\n            return CondenseQuestionChatEngine.from_defaults(\n                query_engine=query_engine,\n                llm=llm,\n                **kwargs,\n            )\n\n        elif chat_mode == ChatMode.CONTEXT:\n            from llama_index.core.chat_engine import ContextChatEngine\n","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/indices/base.py#L531-L567","documentation":"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.","triggerScenarios":"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.","commonSituations":"Upgrading llama-index across the agent deprecation boundary and hitting the removal; old tutorials/blogs showing ChatMode.REACT with a query engine tool.","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.)."],"exampleFix":"# before\nchat_engine = index.as_chat_engine(chat_mode=ChatMode.REACT)\n\n# after\nfrom llama_index.core.agent.workflow import FunctionAgent\nfrom llama_index.core.tools import QueryEngineTool\n\nagent = FunctionAgent(\n    tools=[QueryEngineTool.from_defaults(query_engine=index.as_query_engine())],\n    llm=Settings.llm,\n)\nresponse = await agent.run(\"What was last quarter's revenue?\")","handlingStrategy":"validation","validationCode":"from llama_index.core.chat_engine import ChatMode\nif chat_mode in (ChatMode.REACT, ChatMode.OPENAI):\n    raise DeprecationWarning(\"Migrate to agent.workflow ReActAgent/FunctionAgent\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Search the codebase for ChatMode.REACT/OPENAI before major llama-index upgrades.","Adopt agent.workflow classes for any agent-with-tools use case."],"tags":["chat-engine","deprecation","agents","api-migration"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}