Skip to content

Fatal process exit when calling df_pai.chat() with SQL agent (no error, no output) #1781

@KANISHKSHUKLA

Description

@KANISHKSHUKLA

System Info

OS version: Windows 11
Python version: 3.10.11
pandasai version: 3.x (latest beta, installed with --pre)
pandasai-litellm version: 0.0.1
DuckDB version: 1.4.0.dev1184
LLM backend: Gemini via LiteLLM

🐛 Describe the bug

When calling df_pai.chat("...") with a simple SQL question, the Python process exits immediately with no error, traceback, or output. This happens even with a tiny CSV and a simple question. Direct DuckDB queries work fine. This appears to be a fatal bug in the pandas-ai 3.x SQL agent or code execution sandbox.

Steps to reproduce:

  1. Use this minimal CSV (Volumes.csv):
    Port,State,Commodity,Entity,Type,Period,Value
    PortA,Fresh,Apple,EntityX,Group,2024-25,12.5
    PortA,Fresh,Banana,EntityY,Tied,2024-25,8.2
    PortB,Dry,Orange,EntityZ,Tied,2024-25,15.0
    PortB,Fresh,Apple,EntityX,Group,2023-24,7.1
    PortC,Dry,Grape,EntityW,Tied,2024-25,5.0
    PortA,Fresh,Apple,EntityY,Tied,2023-24,3.3
    PortC,Fresh,Banana,EntityZ,Group,2023-24,6.7
    PortB,Dry,Grape,EntityW,Tied,2023-24,2.2

  2. Use this minimal script:
    import pandas as pd
    import pandasai as pai
    from pandasai_litellm import LiteLLM
    from pandasai.dataframe import DataFrame as PandasAIDataFrame
    import os
    from dotenv import load_dotenv

    load_dotenv()
    df = pd.read_csv("Volumes.csv")
    llm = LiteLLM(model="gemini/gemini-2.5-flash", api_key=os.environ.get("GEMINI_API_KEY"))
    pai.config.set({"llm": llm})
    df_pai = PandasAIDataFrame(df)
    print("Before LLM call")
    print(df_pai.chat("What is the total value for Mundra in 2024-25?"))
    print("After LLM call")

  3. Run the script:
    python test.py

Expected behavior:

  • The script should print "Before LLM call", then the answer, then "After LLM call".

Actual behavior:

  • The script prints "Before LLM call" and then the process exits immediately.
  • No error, no traceback, no output.
  • No crash when running the equivalent SQL directly with DuckDB.

What I tried:

  • Used a tiny CSV (8 rows).
  • Ran direct DuckDB queries (they work fine).
  • Tried in both Streamlit and plain Python script (same result).
  • Upgraded all packages to latest versions.
  • Tried with both gemini/gemini-2.5-flash and gemini/gemini-2.5-pro.

Additional info:

  • This looks like a fatal bug in the pandas-ai 3.x SQL agent or its code execution sandbox.
  • Please advise on a workaround or fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions