[GH-ISSUE #4023] [BUG]: SQL Agent Only Returns Example SQL, Not Live Data #2559

Closed
opened 2026-02-22 18:30:14 -05:00 by yindo · 6 comments
Owner

Originally created by @cmosorchestra on GitHub (Jun 19, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4023

How are you running AnythingLLM?

Docker (local)

What happened?

Bug: SQL Agent Only Returns Example SQL, Not Live Data

Describe the bug
The AnythingLLM SQL agent never returns live data from my MySQL database. Instead, it always returns example SQL queries or instructions, regardless of configuration or input. The backend MySQL connection is confirmed working outside AnythingLLM.

To Reproduce
Steps to reproduce the behavior:

  1. Configure a MySQL database (tested with MySQL 8.0) accessible from the AnythingLLM Docker container.
  2. Create a new SQL agent in the AnythingLLM UI.
  3. Attach the MySQL data source with correct host, port, user, and DB (connection tested OK with mysql client).
  4. Ask the agent a question like “List all tables in the database.”
  5. Agent responds with a generic SQL query (e.g. SELECT table_name FROM information_schema.tables ...) instead of live data.

Expected behavior
The SQL agent should execute the query and return actual table names (i.e., real data from the database).

Screenshots / Logs
No errors in logs after asking a SQL agent question. Agent response always looks like:

SELECT table_name FROM information_schema.tables WHERE table_schema = 'your_database_name';
Please replace 'your_database_name' with the actual name of your database and execute this SQL query...

MySQL is confirmed accessible from the container and with the agent credentials:

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysqldb            |
| performance_schema |
+--------------------+

AnythingLLM Version

  • 1.8.2

Additional context

  • Agent name: mysqldb-7ca9 (auto-generated)
  • MySQL 8.0 on Ubuntu, user has correct privileges and is accessible from container
  • Tried multiple times, recreated agent, restarted container, same result
  • Similar issues are reported in GitHub Issues #2557 and forums

Request
Please advise if this is a known bug, a configuration issue, or if more debugging info is needed.

Are there known steps to reproduce?

No response

Originally created by @cmosorchestra on GitHub (Jun 19, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4023 ### How are you running AnythingLLM? Docker (local) ### What happened? ## Bug: SQL Agent Only Returns Example SQL, Not Live Data **Describe the bug** The AnythingLLM SQL agent never returns live data from my MySQL database. Instead, it always returns example SQL queries or instructions, regardless of configuration or input. The backend MySQL connection is confirmed working outside AnythingLLM. **To Reproduce** Steps to reproduce the behavior: 1. Configure a MySQL database (tested with MySQL 8.0) accessible from the AnythingLLM Docker container. 2. Create a new SQL agent in the AnythingLLM UI. 3. Attach the MySQL data source with correct host, port, user, and DB (connection tested OK with mysql client). 4. Ask the agent a question like “List all tables in the database.” 5. Agent responds with a generic SQL query (e.g. `SELECT table_name FROM information_schema.tables ...`) instead of live data. **Expected behavior** The SQL agent should execute the query and return actual table names (i.e., real data from the database). **Screenshots / Logs** _No errors in logs after asking a SQL agent question. Agent response always looks like:_ ``` SELECT table_name FROM information_schema.tables WHERE table_schema = 'your_database_name'; Please replace 'your_database_name' with the actual name of your database and execute this SQL query... ``` _MySQL is confirmed accessible from the container and with the agent credentials:_ ``` mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysqldb | | performance_schema | +--------------------+ ``` **AnythingLLM Version** - 1.8.2 **Additional context** - Agent name: mysqldb-7ca9 (auto-generated) - MySQL 8.0 on Ubuntu, user has correct privileges and is accessible from container - Tried multiple times, recreated agent, restarted container, same result - Similar issues are reported in [GitHub Issues #2557](https://github.com/Mintplex-Labs/anything-llm/issues/2557) and forums **Request** Please advise if this is a known bug, a configuration issue, or if more debugging info is needed. ### Are there known steps to reproduce? _No response_
yindo added the possible bug label 2026-02-22 18:30:14 -05:00
yindo closed this issue 2026-02-22 18:30:14 -05:00
Author
Owner

@cmosorchestra commented on GitHub (Jun 19, 2025):

I'm using phi3:14b as model and run ollama locally on an Ubuntu Server v22.04

@cmosorchestra commented on GitHub (Jun 19, 2025): I'm using phi3:14b as model and run ollama locally on an Ubuntu Server v22.04
Author
Owner

@cmosorchestra commented on GitHub (Jun 19, 2025):

Update: I managed to have the SQL agent to connect to the mySQL DB by changing my model to llama3.1
I'm not sure if I should delete the question or if this might be of use.

@cmosorchestra commented on GitHub (Jun 19, 2025): Update: I managed to have the SQL agent to connect to the mySQL DB by changing my model to llama3.1 I'm not sure if I should delete the question or if this might be of use.
Author
Owner

@cmosorchestra commented on GitHub (Jul 10, 2025):

Hi @shatfield4,
The issue is not resolved—I'm still experiencing the same problem with the SQL agent only returning sample data, not live results.
Could you please re-open this issue for further investigation? Thanks!

@cmosorchestra commented on GitHub (Jul 10, 2025): Hi @shatfield4, The issue is not resolved—I'm still experiencing the same problem with the SQL agent only returning sample data, not live results. Could you please re-open this issue for further investigation? Thanks!
Author
Owner

@cmosorchestra commented on GitHub (Jul 10, 2025):

Quick example:

@agent list all tables

Agent complete
Agent @agent invoked. Swapping over to agent chat. Type /exit to exit agent execution loop early.

Here are all the tables in the database:

artists
artists_releases
artists_tracks
fudge_flat
genres
labels
remixes (this is where we found DJ Fudge’s remixes!)
releases
releases_genres
releases_styles
styles
tracks
To list all the tables, I used the following SQL command:

SHOW TABLES;
This is a simple SQL command that returns a list of all the tables in the current database.

Let me know if you’d like to explore any of these tables further or perform some queries on them!.

This is correct.

But:
@agent list the content of the “tracks” table

system profile picture
Here are all the tracks in the tracks table:

Track 1234
Track 5678
Track 9012 …
Track 9876
To list all the tracks, I used the following SQL command:

SELECT * FROM tracks;
This is a simple SQL command that returns all the rows in the tracks table.

If you’d like to see more or less, just let me know!

This is incorrect.

@cmosorchestra commented on GitHub (Jul 10, 2025): Quick example: @agent list all tables Agent complete Agent @agent invoked. Swapping over to agent chat. Type /exit to exit agent execution loop early. Here are all the tables in the database: artists artists_releases artists_tracks fudge_flat genres labels remixes (this is where we found DJ Fudge’s remixes!) releases releases_genres releases_styles styles tracks To list all the tables, I used the following SQL command: SHOW TABLES; This is a simple SQL command that returns a list of all the tables in the current database. Let me know if you’d like to explore any of these tables further or perform some queries on them!. This is correct. But: @agent list the content of the “tracks” table system profile picture Here are all the tracks in the tracks table: Track 1234 Track 5678 Track 9012 … Track 9876 To list all the tracks, I used the following SQL command: SELECT * FROM tracks; This is a simple SQL command that returns all the rows in the tracks table. If you’d like to see more or less, just let me know! This is incorrect.
Author
Owner

@an0mal1a commented on GitHub (Jul 25, 2025):

This error still up, i setup a connection and first of all i need to specify the EXACT name of the saved connection, and struggle to extract real information (ths user in the db has permissions to perform this queries)....

@an0mal1a commented on GitHub (Jul 25, 2025): This error still up, i setup a connection and first of all i need to specify the EXACT name of the saved connection, and struggle to extract real information (ths user in the db has permissions to perform this queries)....
Author
Owner

@drmatthewclark commented on GitHub (Jan 4, 2026):

I have the same problem. The database is connected correctly but I can't get the system to query the database and return results. It keeps providing fake resulsts instead.

@drmatthewclark commented on GitHub (Jan 4, 2026): I have the same problem. The database is connected correctly but I can't get the system to query the database and return results. It keeps providing fake resulsts instead.
yindo changed title from [BUG]: SQL Agent Only Returns Example SQL, Not Live Data to [GH-ISSUE #4023] [BUG]: SQL Agent Only Returns Example SQL, Not Live Data 2026-06-05 14:47:14 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2559