ragflow icon indicating copy to clipboard operation
ragflow copied to clipboard

[Bug]: Error when calling non-stream API with agent completion

Open lamhktommy opened this issue 1 month ago • 4 comments

Self Checks

  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (Language Policy).
  • [x] Non-english title submitions will be closed directly ( 非英文标题的提交将会被直接关闭 ) (Language Policy).
  • [x] Please do not modify this template :) and fill in all the required fields.

RAGFlow workspace code commit ID

v0.19.1

RAGFlow image version

v0.19.1-slim

Other environment information

OS: Ubuntu 24.04 LTS
LLM model use: Qwen3-14B

Actual behavior

When I call API for an agent (non-stream):

Error returned: "**ERROR**: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."

Returned Response:

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "logprobs": null,
            "message": {
                "content": "**ERROR**: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().",
                "role": "assistant"
            }
        }
    ],
    "created": null,
    "id": "d1d7e692c9e411f0a746e29ce06e4eac",
    "model": "7c65978cc9c511f0ba42e29ce06e4eac",
    "object": "chat.completion",
    "param": null,
    "usage": {
        "completion_tokens": 29,
        "completion_tokens_details": {
            "accepted_prediction_tokens": 0,
            "reasoning_tokens": 0,
            "rejected_prediction_tokens": 0
        },
        "prompt_tokens": 5,
        "total_tokens": 34
    }
}

Expected behavior

Expected to be no error

Steps to reproduce

1. Create a knowledge base with any documents
2. Create / Import Agent with below json (In additional info)
3. Call Agent completion API 

Example Request body 

{
    "model": "model",
    "messages": [
        {
            "role": "user",
            "content": "summarize documents"
        }
    ],
    "stream": false
}

Additional information

Example Agent

{
  "nodes": [
    {
      "data": { "label": "Begin", "name": "begin" },
      "dragging": false,
      "id": "begin",
      "measured": { "height": 44, "width": 200 },
      "position": { "x": -19.722962059478334, "y": 254.56579639437433 },
      "selected": false,
      "sourcePosition": "left",
      "targetPosition": "right",
      "type": "beginNode"
    },
    {
      "data": { "form": {}, "label": "Answer", "name": "Input" },
      "dragging": false,
      "id": "Answer:SevenGhostsFeel",
      "measured": { "height": 44, "width": 200 },
      "position": { "x": 321.0942993990624, "y": 228.47149699531195 },
      "selected": false,
      "sourcePosition": "right",
      "targetPosition": "left",
      "type": "logicNode"
    },
    {
      "data": {
        "form": {
          "frequencyPenaltyEnabled": false,
          "frequency_penalty": 0.7,
          "language": "",
          "llm_id": "Qwen3-14B@GPUStack",
          "maxTokensEnabled": false,
          "max_tokens": 256,
          "message_history_window_size": 6,
          "presencePenaltyEnabled": false,
          "presence_penalty": 0.4,
          "temperature": 0.1,
          "temperatureEnabled": false,
          "topPEnabled": false,
          "top_p": 0.3
        },
        "label": "RewriteQuestion",
        "name": "Rewrite Question"
      },
      "id": "RewriteQuestion:FewAreasLive",
      "measured": { "height": 102, "width": 200 },
      "position": { "x": 615, "y": 120 },
      "selected": false,
      "sourcePosition": "right",
      "targetPosition": "left",
      "type": "rewriteNode"
    },
    {
      "data": {
        "form": {
          "category_description": {
            "Knowledge Base Question": {
              "index": 1,
              "to": "Retrieval:trueRoomsOccur"
            },
            "Small Talk": {
              "examples": "Hi\nHow are you?",
              "index": 0,
              "to": "Generate:FairMangosSin"
            }
          },
          "frequencyPenaltyEnabled": false,
          "frequency_penalty": 0.7,
          "llm_id": "Qwen3-14B@GPUStack",
          "maxTokensEnabled": false,
          "max_tokens": 256,
          "message_history_window_size": 1,
          "presencePenaltyEnabled": false,
          "presence_penalty": 0.4,
          "query": [
            { "component_id": "Answer:SevenGhostsFeel", "type": "reference" },
            {
              "component_id": "RewriteQuestion:FewAreasLive",
              "type": "reference"
            }
          ],
          "temperature": 0.1,
          "temperatureEnabled": false,
          "topPEnabled": false,
          "top_p": 0.3
        },
        "label": "Categorize",
        "name": "Categorize Question"
      },
      "dragging": false,
      "id": "Categorize:PunyWeeksMix",
      "measured": { "height": 170, "width": 200 },
      "position": { "x": 1037.2456048075007, "y": 119.84283433489603 },
      "selected": false,
      "sourcePosition": "right",
      "targetPosition": "left",
      "type": "categorizeNode"
    },
    {
      "data": {
        "form": {
          "cite": true,
          "frequencyPenaltyEnabled": false,
          "frequency_penalty": 0.7,
          "llm_id": "Qwen3-14B@GPUStack",
          "maxTokensEnabled": false,
          "max_tokens": 256,
          "message_history_window_size": 12,
          "parameters": [],
          "presencePenaltyEnabled": false,
          "presence_penalty": 0.4,
          "prompt": "/nothink As a EMSD assistant, please answer the question",
          "temperature": 0.1,
          "temperatureEnabled": false,
          "topPEnabled": false,
          "top_p": 0.3
        },
        "label": "Generate",
        "name": "Small Talk Answer"
      },
      "dragging": false,
      "id": "Generate:FairMangosSin",
      "measured": { "height": 102, "width": 200 },
      "position": { "x": 677.8742674679168, "y": 370.2956846353648 },
      "selected": false,
      "sourcePosition": "right",
      "targetPosition": "left",
      "type": "generateNode"
    },
    {
      "data": {
        "form": {
          "cite": true,
          "frequencyPenaltyEnabled": false,
          "frequency_penalty": 0.7,
          "llm_id": "Qwen3-14B@GPUStack",
          "maxTokensEnabled": false,
          "max_tokens": 256,
          "message_history_window_size": 12,
          "parameters": [],
          "presencePenaltyEnabled": false,
          "presence_penalty": 0.4,
          "prompt": "Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:\n        {input}\n  The above is the content you need to summarize.",
          "temperature": 0.1,
          "temperatureEnabled": false,
          "topPEnabled": false,
          "top_p": 0.3
        },
        "label": "Generate",
        "name": "Generate answer"
      },
      "dragging": false,
      "id": "Generate:LittleTownsAsk",
      "measured": { "height": 102, "width": 200 },
      "position": { "x": 434.9334053269862, "y": 573.9184870391152 },
      "selected": false,
      "sourcePosition": "right",
      "targetPosition": "left",
      "type": "generateNode"
    },
    {
      "data": {
        "form": {
          "kb_ids": ["6f566cd4c9c411f08811e29ce06e4eac"],
          "keywords_similarity_weight": 0.5,
          "query": [
            {
              "component_id": "RewriteQuestion:FewAreasLive",
              "type": "reference"
            },
            { "component_id": "Answer:SevenGhostsFeel", "type": "reference" }
          ],
          "rerank_id": "bge-reranker-v2-m3@GPUStack",
          "similarity_threshold": 0.3,
          "top_k": 1024,
          "top_n": 8,
          "use_kg": false
        },
        "label": "Retrieval",
        "name": "Knowledge Base Retrieval"
      },
      "id": "Retrieval:trueRoomsOccur",
      "measured": { "height": 106, "width": 200 },
      "position": { "x": 885, "y": 570 },
      "selected": false,
      "sourcePosition": "right",
      "targetPosition": "left",
      "type": "retrievalNode"
    }
  ],
  "edges": [
    {
      "id": "xy-edge__begin-Answer:SevenGhostsFeelc",
      "markerEnd": "logo",
      "source": "begin",
      "style": { "stroke": "rgb(202 197 245)", "strokeWidth": 2 },
      "target": "Answer:SevenGhostsFeel",
      "targetHandle": "c",
      "type": "buttonEdge",
      "zIndex": 1001
    },
    {
      "id": "xy-edge__Answer:SevenGhostsFeelb-RewriteQuestion:FewAreasLivec",
      "markerEnd": "logo",
      "source": "Answer:SevenGhostsFeel",
      "sourceHandle": "b",
      "style": { "stroke": "rgb(202 197 245)", "strokeWidth": 2 },
      "target": "RewriteQuestion:FewAreasLive",
      "targetHandle": "c",
      "type": "buttonEdge",
      "zIndex": 1001
    },
    {
      "id": "xy-edge__RewriteQuestion:FewAreasLiveb-Categorize:PunyWeeksMixa",
      "markerEnd": "logo",
      "source": "RewriteQuestion:FewAreasLive",
      "sourceHandle": "b",
      "style": { "stroke": "rgb(202 197 245)", "strokeWidth": 2 },
      "target": "Categorize:PunyWeeksMix",
      "targetHandle": "a",
      "type": "buttonEdge",
      "zIndex": 1001
    },
    {
      "id": "xy-edge__Retrieval:trueRoomsOccurc-Generate:LittleTownsAskb",
      "markerEnd": "logo",
      "source": "Retrieval:trueRoomsOccur",
      "sourceHandle": "c",
      "style": { "stroke": "rgb(202 197 245)", "strokeWidth": 2 },
      "target": "Generate:LittleTownsAsk",
      "targetHandle": "b",
      "type": "buttonEdge",
      "zIndex": 1001
    },
    {
      "id": "xy-edge__Generate:LittleTownsAskc-Answer:SevenGhostsFeelc",
      "markerEnd": "logo",
      "source": "Generate:LittleTownsAsk",
      "sourceHandle": "c",
      "style": { "stroke": "rgb(202 197 245)", "strokeWidth": 2 },
      "target": "Answer:SevenGhostsFeel",
      "targetHandle": "c",
      "type": "buttonEdge",
      "zIndex": 1001
    },
    {
      "id": "xy-edge__Generate:FairMangosSinc-Answer:SevenGhostsFeelc",
      "markerEnd": "logo",
      "source": "Generate:FairMangosSin",
      "sourceHandle": "c",
      "style": { "stroke": "rgb(202 197 245)", "strokeWidth": 2 },
      "target": "Answer:SevenGhostsFeel",
      "targetHandle": "c",
      "type": "buttonEdge",
      "zIndex": 1001
    },
    {
      "id": "xy-edge__Categorize:PunyWeeksMixSmall Talk-Generate:FairMangosSinb",
      "markerEnd": "logo",
      "source": "Categorize:PunyWeeksMix",
      "sourceHandle": "Small Talk",
      "style": { "stroke": "rgb(202 197 245)", "strokeWidth": 2 },
      "target": "Generate:FairMangosSin",
      "targetHandle": "b",
      "type": "buttonEdge",
      "zIndex": 1001
    },
    {
      "id": "xy-edge__Categorize:PunyWeeksMixKnowledge Base Question-Retrieval:trueRoomsOccurb",
      "markerEnd": "logo",
      "source": "Categorize:PunyWeeksMix",
      "sourceHandle": "Knowledge Base Question",
      "style": { "stroke": "rgb(202 197 245)", "strokeWidth": 2 },
      "target": "Retrieval:trueRoomsOccur",
      "targetHandle": "b",
      "type": "buttonEdge",
      "zIndex": 1001
    }
  ]
}

lamhktommy avatar Nov 25 '25 10:11 lamhktommy

This error happens because RAGFlow v0.19.1 sometimes passes a pandas Series (or DataFrame column) into a boolean check without aggregation, especially during document retrieval or aggregation steps in agent workflows. For example, in the Infinity connector, code like if pd.isna(value) or not value: will fail if value is a Series instead of a scalar, which can happen when agent nodes (retrieval, categorization, summarization) process results from the knowledge base. This is a known bug and has been fixed in later versions of RAGFlow by making these checks more robust to Series inputs see code reference.

The most reliable solution is to upgrade to a newer version of RAGFlow, where these pandas handling bugs are fixed. If you can't upgrade, you might be able to work around the issue by simplifying your agent workflow: try reducing the number of fields returned by retrieval nodes, avoid using document/tag fields that could be lists or arrays, or test each node in isolation to find which one triggers the error.

If you can share more about your knowledge base structure or which node triggers the error, I can help suggest more targeted workarounds.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

dosubot[bot] avatar Nov 25 '25 10:11 dosubot[bot]

@dosu I am using Elastic Search, not Infinity. Help me find the problematic code which causing this error

lamhktommy avatar Nov 25 '25 10:11 lamhktommy

The "truth value of a Series is ambiguous" error is not caused by the ElasticSearch connector or retrieval nodes in RAGFlow—they return plain Python dicts and lists, not pandas objects, and do not perform boolean checks that would trigger this error (es_conn.py, Dealer in search.py, retrieval agent node). The only places in the codebase that use pandas and have this kind of boolean logic are for the Infinity backend or in table/chunk parsers, which are not used in the standard ElasticSearch agent flow.

If you are seeing this error with ElasticSearch, double-check that your DOC_ENGINE is set to "elasticsearch" and not "infinity". If that's correct, the error is likely coming from a downstream utility or a custom node that wraps or processes retrieval results with pandas—possibly in a summarization or table-processing step. Look for any code that does something like if value: or if not value: where value could be a pandas Series, especially after document retrieval or chunking.

If you have custom nodes or plugins, check those for pandas usage. Otherwise, this bug should not occur in the standard ElasticSearch agent workflow in RAGFlow v0.19.1.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

dosubot[bot] avatar Nov 25 '25 10:11 dosubot[bot]

@dosu it only happens when i have a Retrieval Node connected with Generate Node in Agent flow.

lamhktommy avatar Nov 26 '25 09:11 lamhktommy