[GH-ISSUE #1805] [BUG]: Agent can't find active connection to MySQL database #1178

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

Originally created by @CedricGoby on GitHub (Jul 3, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/1805

How are you running AnythingLLM?

Docker (local)

What happened?

After setting up a SQL Connector (MySQL) the agent answer there is no active connection to the database if I ask for the list of the tables of the database.

I'm using the MistralAI API with mistral-large-2402 model.

This is the logs from AnythingLLM :

[Event Logged] - sent_chat
[AgentHandler] Start 46b3df8f-f99b-4099-b1e6-688241ebfe71::mistral:mistral-large-2402
[TELEMETRY SENT] {
  event: 'agent_chat_started',
  distinctId: 'f322ff19-73c2-47a9-8aa2-32c59ce7d737',
  properties: { runtime: 'docker' }
}
[AgentHandler] Attached websocket plugin to Agent cluster
[AgentHandler] Attached chat-history plugin to Agent cluster
[AgentHandler] Attaching user and default agent to Agent cluster.
[AgentHandler] Attached rag-memory plugin to Agent cluster
[AgentHandler] Attached document-summarizer plugin to Agent cluster
[AgentHandler] Attached web-scraping plugin to Agent cluster
[AgentHandler] Attached sql-agent:sql-list-databases plugin to Agent cluster
[AgentHandler] Attached sql-agent:sql-list-tables plugin to Agent cluster
[AgentHandler] Attached sql-agent:sql-get-table-schema plugin to Agent cluster
[AgentHandler] Attached sql-agent:sql-query plugin to Agent cluster
[AgentLLM - mistral-large-2402] Valid tool call found - running sql-list-tables.
[AgentHandler] [debug]: @agent is attempting to call `sql-list-tables` tool
[AgentHandler] Using the sql-list-tables tool.
[AgentHandler] sql-list-tables failed to find config!. mydatabase
[AgentLLM - mistral-large-2402] Function tool with exact arguments has already been called this stack.
[AgentLLM - mistral-large-2402] Will assume chat completion without tool call inputs.

Are there known steps to reproduce?

  • Start a fresh test stack using a docker-compose file (don't use it for production, it's ugly and insecure)
# AI Stack
# Licence : GPL-3+ (https://www.gnu.org/licenses/gpl-3.0.txt)
# Auteur : Cédric Goby

services:
  # AnythingLLM
  # https://github.com/Mintplex-Labs/anything-llm/blob/master/docker/HOW_TO_USE_DOCKER.md
  # https://hub.docker.com/r/mintplexlabs/anythingllm/tags
  anything_llm:
    image: mintplexlabs/anythingllm:master
    container_name: anything_llm
    ports:
      - "3001:3001"
    cap_add:
      - SYS_ADMIN
    networks:
      - frontend
    volumes:
      - "$HOME/Documents/DEV/IA/Desktop/anything-llm/persistent:/app/server/storage"
      - "$HOME/Documents/DEV/IA/Desktop/anything-llm/persistent/.env:/app/server/.env"
    environment:
      - STORAGE_DIR=/app/server/storage

  # Chroma
  # https://github.com/chroma-core/chroma/blob/main/docker-compose.yml
  # https://hub.docker.com/r/chromadb/chroma/tags
  chroma:
    image: chromadb/chroma:0.5.1.dev173
    container_name: chroma
    ports:
      - "8000:8000"
    networks:
      - frontend
    volumes:
      - "$HOME/Documents/DEV/IA/Desktop/chroma/persistent:/chroma/chroma"

  # PostgreSQL (pour VectorAdmin)
  # https://github.com/docker-library/docs/blob/master/postgres/README.md
  # https://hub.docker.com/_/postgres/tags
  postgres:
    image: postgres:13.15-bookworm
    container_name: vectoradmin_postgres
    ports:
      - "5432:5432"
    networks:
      - frontend
    volumes:
      - $HOME/Documents/DEV/IA/Desktop/vectoradmin/postgresql/persistent:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: vectoradmin
      POSTGRES_PASSWORD: password
      POSTGRES_DB: vdbms

  # VectorAdmin
  # https://github.com/Mintplex-Labs/vector-admin/blob/master/docker/DOCKER.md
  # https://hub.docker.com/r/mintplexlabs/vectoradmin/tags
  vectoradmin:
    image: mintplexlabs/vectoradmin
    container_name: vectoradmin
    ports:
      - "3002:3002"
    networks:
      - frontend
    volumes:
      - "$HOME/Documents/DEV/IA/Desktop/vectoradmin/persistent/backend/storage:/app/backend/storage"
      #- "$HOME/Documents/DEV/IA/Desktop/vectoradmin/persistent/.env:/app/backend/.env"
      - "$HOME/Documents/DEV/IA/Desktop/vectoradmin/persistent/document-processor/hotdir:/app/document-processor/hotdir"
    environment:
      - SERVER_PORT=3002
      - JWT_SECRET=password
      - INNGEST_EVENT_KEY=background_workers
      - INNGEST_SIGNING_KEY=password
      - INNGEST_LANDING_PAGE=true
      - DATABASE_CONNECTION_STRING=postgresql://vectoradmin:password@postgres:5432/vdbms
      - DISABLE_TELEMETRY="true"
    depends_on:
      - postgres

# MySQL
# https://dev.mysql.com/doc/refman/8.0/en/docker-mysql-more-topics.html
  mysql:
    image: mysql:8.0.33
    container_name: mysql
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: password
    command: --default-authentication-plugin=caching_sha2_password
    restart: always
    networks:
      - frontend
    volumes:
      - "$HOME/Documents/DEV/IA/Desktop/mysql/persistent/data:/var/lib/mysql"
      - "$HOME/Documents/DEV/IA/Desktop/mysql/persistent/config:/etc/mysql/conf.d"

# SERVICE PHPMYADMIN
# https://github.com/phpmyadmin/docker
  phpmyadmin:
    image: phpmyadmin:5.2.1-apache
    container_name: phpmyadmin
    ports:
      - "8080:80"
    networks:
      - frontend
    environment:
      PMA_ARBITRARY: 1
    restart: always

networks:
  frontend:
    external: true
  • Open a new AnythingLLM workspace (http://localhost:3001/)
  • Go to "Agent configuration / Configure Agent Skills"
  • Go to "SQL Connector"
  • Switch to "On" and configure a mysql database connexion.
    The "Server endpoint" is the IP of the mysql container (eg 172.20.0.5)
  • Save settings and go back to the chat of the workspace
  • Ask for the list of the tables of the databse
  • The agent answer : "I’m sorry for the inconvenience. It seems there’s no active connection to the database “mydatabase”. Please ensure you’ve established a connection to the database before running your query. If you need help with setting up a connection, feel free to ask!"

If you look at the capabilities of the agent you don't see SQL Connector :

Capture d’écran du 2024-07-03 11-21-58

You can verify that the database is reachable from inside the AnythingLLM container with the same database connection settings :

me@my-laptop:~$ docker exec -u root -it anything_llm bash

root@6099cb6fb8d9:/app# apt update
...
root@6099cb6fb8d9:/app# apt install default-mysql-client
...
root@6099cb6fb8d9:/app# mysql -uroot -p -h 172.20.0.5 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 87
Server version: 8.0.33 MySQL Community Server - GPL
...
mysql>

The database is also reachable using phpmyadmin (http://localhost:8080/)

Can someone help me ?

Originally created by @CedricGoby on GitHub (Jul 3, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/1805 ### How are you running AnythingLLM? Docker (local) ### What happened? After setting up a SQL Connector (MySQL) the agent answer there is no active connection to the database if I ask for the list of the tables of the database. I'm using the MistralAI API with mistral-large-2402 model. This is the logs from AnythingLLM : ``` [Event Logged] - sent_chat [AgentHandler] Start 46b3df8f-f99b-4099-b1e6-688241ebfe71::mistral:mistral-large-2402 [TELEMETRY SENT] { event: 'agent_chat_started', distinctId: 'f322ff19-73c2-47a9-8aa2-32c59ce7d737', properties: { runtime: 'docker' } } [AgentHandler] Attached websocket plugin to Agent cluster [AgentHandler] Attached chat-history plugin to Agent cluster [AgentHandler] Attaching user and default agent to Agent cluster. [AgentHandler] Attached rag-memory plugin to Agent cluster [AgentHandler] Attached document-summarizer plugin to Agent cluster [AgentHandler] Attached web-scraping plugin to Agent cluster [AgentHandler] Attached sql-agent:sql-list-databases plugin to Agent cluster [AgentHandler] Attached sql-agent:sql-list-tables plugin to Agent cluster [AgentHandler] Attached sql-agent:sql-get-table-schema plugin to Agent cluster [AgentHandler] Attached sql-agent:sql-query plugin to Agent cluster [AgentLLM - mistral-large-2402] Valid tool call found - running sql-list-tables. [AgentHandler] [debug]: @agent is attempting to call `sql-list-tables` tool [AgentHandler] Using the sql-list-tables tool. [AgentHandler] sql-list-tables failed to find config!. mydatabase [AgentLLM - mistral-large-2402] Function tool with exact arguments has already been called this stack. [AgentLLM - mistral-large-2402] Will assume chat completion without tool call inputs. ``` ### Are there known steps to reproduce? - Start a fresh test stack using a docker-compose file (don't use it for production, it's ugly and insecure) ``` # AI Stack # Licence : GPL-3+ (https://www.gnu.org/licenses/gpl-3.0.txt) # Auteur : Cédric Goby services: # AnythingLLM # https://github.com/Mintplex-Labs/anything-llm/blob/master/docker/HOW_TO_USE_DOCKER.md # https://hub.docker.com/r/mintplexlabs/anythingllm/tags anything_llm: image: mintplexlabs/anythingllm:master container_name: anything_llm ports: - "3001:3001" cap_add: - SYS_ADMIN networks: - frontend volumes: - "$HOME/Documents/DEV/IA/Desktop/anything-llm/persistent:/app/server/storage" - "$HOME/Documents/DEV/IA/Desktop/anything-llm/persistent/.env:/app/server/.env" environment: - STORAGE_DIR=/app/server/storage # Chroma # https://github.com/chroma-core/chroma/blob/main/docker-compose.yml # https://hub.docker.com/r/chromadb/chroma/tags chroma: image: chromadb/chroma:0.5.1.dev173 container_name: chroma ports: - "8000:8000" networks: - frontend volumes: - "$HOME/Documents/DEV/IA/Desktop/chroma/persistent:/chroma/chroma" # PostgreSQL (pour VectorAdmin) # https://github.com/docker-library/docs/blob/master/postgres/README.md # https://hub.docker.com/_/postgres/tags postgres: image: postgres:13.15-bookworm container_name: vectoradmin_postgres ports: - "5432:5432" networks: - frontend volumes: - $HOME/Documents/DEV/IA/Desktop/vectoradmin/postgresql/persistent:/var/lib/postgresql/data environment: POSTGRES_USER: vectoradmin POSTGRES_PASSWORD: password POSTGRES_DB: vdbms # VectorAdmin # https://github.com/Mintplex-Labs/vector-admin/blob/master/docker/DOCKER.md # https://hub.docker.com/r/mintplexlabs/vectoradmin/tags vectoradmin: image: mintplexlabs/vectoradmin container_name: vectoradmin ports: - "3002:3002" networks: - frontend volumes: - "$HOME/Documents/DEV/IA/Desktop/vectoradmin/persistent/backend/storage:/app/backend/storage" #- "$HOME/Documents/DEV/IA/Desktop/vectoradmin/persistent/.env:/app/backend/.env" - "$HOME/Documents/DEV/IA/Desktop/vectoradmin/persistent/document-processor/hotdir:/app/document-processor/hotdir" environment: - SERVER_PORT=3002 - JWT_SECRET=password - INNGEST_EVENT_KEY=background_workers - INNGEST_SIGNING_KEY=password - INNGEST_LANDING_PAGE=true - DATABASE_CONNECTION_STRING=postgresql://vectoradmin:password@postgres:5432/vdbms - DISABLE_TELEMETRY="true" depends_on: - postgres # MySQL # https://dev.mysql.com/doc/refman/8.0/en/docker-mysql-more-topics.html mysql: image: mysql:8.0.33 container_name: mysql ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: password command: --default-authentication-plugin=caching_sha2_password restart: always networks: - frontend volumes: - "$HOME/Documents/DEV/IA/Desktop/mysql/persistent/data:/var/lib/mysql" - "$HOME/Documents/DEV/IA/Desktop/mysql/persistent/config:/etc/mysql/conf.d" # SERVICE PHPMYADMIN # https://github.com/phpmyadmin/docker phpmyadmin: image: phpmyadmin:5.2.1-apache container_name: phpmyadmin ports: - "8080:80" networks: - frontend environment: PMA_ARBITRARY: 1 restart: always networks: frontend: external: true ``` - Open a new AnythingLLM workspace (http://localhost:3001/) - Go to "Agent configuration / Configure Agent Skills" - Go to "SQL Connector" - Switch to "On" and configure a mysql database connexion. The "Server endpoint" is the IP of the mysql container (eg 172.20.0.5) - Save settings and go back to the chat of the workspace - Ask for the list of the tables of the databse - The agent answer : "I’m sorry for the inconvenience. It seems there’s no active connection to the database “mydatabase”. Please ensure you’ve established a connection to the database before running your query. If you need help with setting up a connection, feel free to ask!" If you look at the capabilities of the agent you don't see SQL Connector : ![Capture d’écran du 2024-07-03 11-21-58](https://github.com/Mintplex-Labs/anything-llm/assets/17612749/0a72982d-9e82-4ec7-a67f-a1e9969ee000) You can verify that the database is reachable from inside the AnythingLLM container with the same database connection settings : ``` me@my-laptop:~$ docker exec -u root -it anything_llm bash root@6099cb6fb8d9:/app# apt update ... root@6099cb6fb8d9:/app# apt install default-mysql-client ... root@6099cb6fb8d9:/app# mysql -uroot -p -h 172.20.0.5 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 87 Server version: 8.0.33 MySQL Community Server - GPL ... mysql> ``` The database is also reachable using phpmyadmin (http://localhost:8080/) Can someone help me ?
yindo added the possible bug label 2026-02-22 18:23:33 -05:00
yindo closed this issue 2026-02-22 18:23:33 -05:00
Author
Owner

@timothycarambat commented on GitHub (Jul 3, 2024):

Looks like the tool call is actually working as intended, but the JSON formed back from the model while passing the schema requirement still has a value of {database_id: "mydatabase"}

When you setup the database - what is in this field? If it is not mydatabase the connector alias wont be found and the model is basically hallucinating the database id. We give it the list of all databases but you can more explicit in your prompt to encourage the model to make a valid call.

eg: Using <connector alias> give me xyz

Screenshot 2024-07-03 at 11 57 28 AM

related docs: https://docs.useanything.com/agent-not-using-tools

@timothycarambat commented on GitHub (Jul 3, 2024): Looks like the tool call is actually working as intended, but the JSON formed back from the model _while passing the schema requirement_ still has a value of `{database_id: "mydatabase"}` When you setup the database - what is in this field? If it is not `mydatabase` the connector alias wont be found and the model is basically hallucinating the database id. We give it the list of all databases but you can more explicit in your prompt to encourage the model to make a valid call. eg: `Using <connector alias> give me xyz` <img width="762" alt="Screenshot 2024-07-03 at 11 57 28 AM" src="https://github.com/Mintplex-Labs/anything-llm/assets/16845892/09c0d5d9-65f1-4c6a-86eb-aa0326c87f5c"> related docs: https://docs.useanything.com/agent-not-using-tools
Author
Owner

@CedricGoby commented on GitHub (Jul 4, 2024):

Thank you very much. Setting "Connection name" to "mydatabase" and be more explicit in the prompt did the trick.

@CedricGoby commented on GitHub (Jul 4, 2024): Thank you very much. Setting "Connection name" to "mydatabase" and be more explicit in the prompt did the trick.
Author
Owner

@esaic commented on GitHub (Jul 7, 2024):

I'm having a similar issue. I have the dockerized version of anything llm and a mysql container spunned up as well. What value did you enter for the server end point? The mysql serever ip?

@esaic commented on GitHub (Jul 7, 2024): I'm having a similar issue. I have the dockerized version of anything llm and a mysql container spunned up as well. What value did you enter for the server end point? The mysql serever ip?
Author
Owner

@CedricGoby commented on GitHub (Jul 9, 2024):

The mysql serever ip?

Yes. this is the IP of the MySQL container (eg : 172.20.0.5).

Because the IP of the container change each time the container is starting you could also use the service name for this field (eg : mysql)

@CedricGoby commented on GitHub (Jul 9, 2024): > The mysql serever ip? Yes. this is the IP of the MySQL container (eg : 172.20.0.5). Because the IP of the container change each time the container is starting you could also use the service name for this field (eg : mysql)
Author
Owner

@esaic commented on GitHub (Jul 9, 2024):

Thank you!

The mysql serever ip?

Yes. this is the IP of the MySQL container (eg : 172.20.0.5).

Because the IP of the container change each time the container is starting you could also use the service name for this field (eg : mysql)

@esaic commented on GitHub (Jul 9, 2024): Thank you! > > The mysql serever ip? > > Yes. this is the IP of the MySQL container (eg : 172.20.0.5). > > Because the IP of the container change each time the container is starting you could also use the service name for this field (eg : mysql)
Author
Owner

@avineetbespin commented on GitHub (Feb 22, 2025):

I get the same issue, tried to use, 'using {connection unique name } and asking for it to show me the information in that table', it just doesn't read the connection and comes with general world responses.

"using the {connection name} database connection, tell me which tables do you see"

AnythingLLM response:

Okay, to answer this question properly, I need to clarify a key point. As a large language model, I don’t “see” databases or tables in the way a human developer or database administrator would. I don’t have direct access to your FinOps database or its schema.

My response must be based on general knowledge of typical FinOps database structures, or based on information you provide to me about the specific FinOps solution and its database schema.

Assuming you are talking about the Azure FinOps solution and are exporting data to a database (e.g., Azure SQL Database, or a similar database that stores exported cost and usage data), I can give you a list of likely table names based on common FinOps/cost management data structures:

@avineetbespin commented on GitHub (Feb 22, 2025): I get the same issue, tried to use, 'using {connection unique name } and asking for it to show me the information in that table', it just doesn't read the connection and comes with general world responses. "using the {connection name} database connection, tell me which tables do you see" AnythingLLM response: Okay, to answer this question properly, I need to clarify a key point. As a large language model, I don’t “see” databases or tables in the way a human developer or database administrator would. I don’t have direct access to your FinOps database or its schema. My response must be based on general knowledge of typical FinOps database structures, or based on information you provide to me about the specific FinOps solution and its database schema. Assuming you are talking about the Azure FinOps solution and are exporting data to a database (e.g., Azure SQL Database, or a similar database that stores exported cost and usage data), I can give you a list of likely table names based on common FinOps/cost management data structures:
yindo changed title from [BUG]: Agent can't find active connection to MySQL database to [GH-ISSUE #1805] [BUG]: Agent can't find active connection to MySQL database 2026-06-05 14:39:22 -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#1178