AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

LLM.Predict_and_call Fails With ValidationError For Non-Function-Calling Models When React_chat_formatter Is Omitted

LLM.predict_and_call and LLM.apredict_and_call construct ReActAgent with formatter=None when react_chat_formatter is not provided, causing pydantic ValidationError. The ReActAgent default factory is bypassed because the key is passed explicitly with a None value.

highConfidence 92%Llama_indexData Connectorsllama-index-coreAffected V0.14.25

Origin Analysis

In llama_index/core/llms/llm.py, the methods pass `formatter=kwargs.get("react_chat_formatter")` to ReActAgent. When the kwarg is absent, kwargs.get returns None, which is passed explicitly. ReActAgent.formatter has `default_factory=default_formatter`, but pydantic only applies the factory when the field is not provided. Passing None violates the type and raises ValidationError before the agent can run.
1. Use llama-index 0.14.25. \n2. Create a chat mock LLM with metadata.is_function_calling_model=False. \n3. Call llm.predict_and_call(tools, user_msg='Capital of France?') without react_chat_formatter. \n4. Observe pydantic ValidationError for ReActAgent formatter field.

Fixing Code Block

Edge Case Audit

Regression risk: If callers pass react_chat_formatter=None explicitly to disable formatter, the validation error will still occur because 'react_chat_formatter' is in kwargs and the value None is forwarded. To be fully defensive, consider skipping the key if value is None. Pydantic v1 vs v2 behavior should be tested. Rollback suggestion: keep the original passing of kwargs.get(...) and instead modify ReActAgent.formatter to allow None and use default when None.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state