crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG]Agent does not appear to pass config or query to Snowflake search tool

Open mbabu-driftwood opened this issue 8 months ago • 10 comments

Description

Using crewai 0.108.0 and crewai tools 0.38.1 Using doc from https://docs.crewai.com/tools/snowflakesearchtool

Steps to Reproduce

Follow instructions on https://docs.crewai.com/tools/snowflakesearchtool

Create a snowflakeserachtool config (replace with actual data)

Create configuration

of course, replaced below with actual values

config = SnowflakeConfig( user=snowflake_user, password=snowflake_password, account=snowflake_account, warehouse=snowflake_warehouse, database=snowflake_database, schema=snowflake_schema )

Initialize tool

tool = SnowflakeSearchTool( config=config, pool_size=5, max_retries=3, enable_caching=True, query="select current_time", database = "TST", snowflake_schema = "PUBLIC", )

Define an agent that uses the tool

data_analyst_agent = Agent( role="Data Analyst", goal="Analyze data from Snowflake database", backstory="An expert data analyst who can extract insights from enterprise data.", tools=[tool], verbose=True, )

Example task to query curr time data

query_task = Task( description="Get the current time from snowflake, schema is PUBLIC, Database is STR", expected_output="Create a report displaying the current time with the words Current time:::", agent=data_analyst_agent, )

Create and run the crew

crew = Crew(agents=[data_analyst_agent], tasks=[query_task], verbose=True, process=Process.sequential, )

Execute query

async def main(): result = crew.kickoff()

if name == "main": asyncio.run(main())

Expected behavior

Print out: Current time:: YYYY-MM-DD HH:MM:SS.ssssss

Screenshots/Code snippets

Follow instructions on https://docs.crewai.com/tools/snowflakesearchtool

Create a snowflakeserachtool config (replace with actual data)

Create configuration

config = SnowflakeConfig( user=snowflake_user, password=snowflake_password, account=snowflake_account, warehouse=snowflake_warehouse, database=snowflake_database, schema=snowflake_schema )

Initialize tool

tool = SnowflakeSearchTool( config=config, pool_size=5, max_retries=3, enable_caching=True, query="select current_time", database = "STR", snowflake_schema = "PUBLIC", )

Define an agent that uses the tool

data_analyst_agent = Agent( role="Data Analyst", goal="Analyze data from Snowflake database", backstory="An expert data analyst who can extract insights from enterprise data.", tools=[tool], verbose=True, )

Example task to query curr time data

query_task = Task( description="Get the current time from snowflake, schema is PUBLIC, Database is STR", expected_output="Create a report displaying the current time with the words Current time:::", agent=data_analyst_agent, )

Create and run the crew

crew = Crew(agents=[data_analyst_agent], tasks=[query_task], verbose=True, process=Process.sequential, )

Execute query

async def main(): result = crew.kickoff()

if name == "main": asyncio.run(main())

Operating System

Windows 11

Python Version

3.12

crewAI Version

0.108.0

crewAI Tools Version

0.38.1

Virtual Environment

Venv

Evidence

Agent: Data Analyst

Task: Get the current time from snowflake, schema is PUBLIC, Database is STR

Agent: Data Analyst

Thought: I need to retrieve the current time from the Snowflake database specified with the correct schema and database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

<coroutine object SnowflakeSearchTool._run at 0x000002882D22E9E0>

Agent: Data Analyst

Thought: Thought: I will execute the query to get the current timestamp from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to execute the query correctly to get the current timestamp from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:

Tool Name: Snowflake Database Search Tool Arguments: {'query': {'description': 'SQL query or semantic search query to execute', 'type': 'str'}, 'database': {'description': 'Override default database', 'type': 'Union[str, NoneType]'}, 'snowflake_schema': {'description': 'Override default schema', 'type': 'Union[str, NoneType]'}, 'timeout': {'description': 'Query timeout in seconds', 'type': 'Union[int, NoneType]'}} Tool Description: Execute SQL queries or semantic search on Snowflake data warehouse. Supports both raw SQL and natural language queries.

IMPORTANT: Use the following format in your response:

Thought: you should always think about what to do
Action: the action to take, only one name of [Snowflake Database Search], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action

Once all necessary information is gathered, return the following format:

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Agent: Data Analyst

Thought: Thought: I should execute the query to get the current time from the specified Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: It's important to pull the current timestamp accurately from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to gather the current timestamp from the Snowflake database with the right parameters.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:

Tool Name: Snowflake Database Search Tool Arguments: {'query': {'description': 'SQL query or semantic search query to execute', 'type': 'str'}, 'database': {'description': 'Override default database', 'type': 'Union[str, NoneType]'}, 'snowflake_schema': {'description': 'Override default schema', 'type': 'Union[str, NoneType]'}, 'timeout': {'description': 'Query timeout in seconds', 'type': 'Union[int, NoneType]'}} Tool Description: Execute SQL queries or semantic search on Snowflake data warehouse. Supports both raw SQL and natural language queries.

IMPORTANT: Use the following format in your response:

Thought: you should always think about what to do
Action: the action to take, only one name of [Snowflake Database Search], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action

Once all necessary information is gathered, return the following format:

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Agent: Data Analyst

Thought: Thought: I need to execute the query to retrieve the current time from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: To get the current time, I need to run the SQL query against the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to correctly execute a query to obtain the current time from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:

Tool Name: Snowflake Database Search Tool Arguments: {'query': {'description': 'SQL query or semantic search query to execute', 'type': 'str'}, 'database': {'description': 'Override default database', 'type': 'Union[str, NoneType]'}, 'snowflake_schema': {'description': 'Override default schema', 'type': 'Union[str, NoneType]'}, 'timeout': {'description': 'Query timeout in seconds', 'type': 'Union[int, NoneType]'}} Tool Description: Execute SQL queries or semantic search on Snowflake data warehouse. Supports both raw SQL and natural language queries.

IMPORTANT: Use the following format in your response:

Thought: you should always think about what to do
Action: the action to take, only one name of [Snowflake Database Search], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action

Once all necessary information is gathered, return the following format:

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Agent: Data Analyst

Thought: Thought: I have to run the query to get the current timestamp from the specified Snowflake database settings.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to run the SQL query correctly to retrieve the current timestamp from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I have to perform the SQL query to obtain the current timestamp from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:

Tool Name: Snowflake Database Search Tool Arguments: {'query': {'description': 'SQL query or semantic search query to execute', 'type': 'str'}, 'database': {'description': 'Override default database', 'type': 'Union[str, NoneType]'}, 'snowflake_schema': {'description': 'Override default schema', 'type': 'Union[str, NoneType]'}, 'timeout': {'description': 'Query timeout in seconds', 'type': 'Union[int, NoneType]'}} Tool Description: Execute SQL queries or semantic search on Snowflake data warehouse. Supports both raw SQL and natural language queries.

IMPORTANT: Use the following format in your response:

Thought: you should always think about what to do
Action: the action to take, only one name of [Snowflake Database Search], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action

Once all necessary information is gathered, return the following format:

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Agent: Data Analyst

Thought: Thought: I must execute the query to get the current timestamp from the Snowflake database correctly.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to execute the query that retrieves the current timestamp from the specified Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to run the appropriate query to retrieve the current time from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:

Tool Name: Snowflake Database Search Tool Arguments: {'query': {'description': 'SQL query or semantic search query to execute', 'type': 'str'}, 'database': {'description': 'Override default database', 'type': 'Union[str, NoneType]'}, 'snowflake_schema': {'description': 'Override default schema', 'type': 'Union[str, NoneType]'}, 'timeout': {'description': 'Query timeout in seconds', 'type': 'Union[int, NoneType]'}} Tool Description: Execute SQL queries or semantic search on Snowflake data warehouse. Supports both raw SQL and natural language queries.

IMPORTANT: Use the following format in your response:

Thought: you should always think about what to do
Action: the action to take, only one name of [Snowflake Database Search], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action

Once all necessary information is gathered, return the following format:

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Agent: Data Analyst

Thought: Thought: I must execute the SQL query to correctly retrieve the current timestamp from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to execute a query to fetch the current time from the Snowflake database accurately.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to attempt executing the SQL query that fetches the current timestamp from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:

Tool Name: Snowflake Database Search Tool Arguments: {'query': {'description': 'SQL query or semantic search query to execute', 'type': 'str'}, 'database': {'description': 'Override default database', 'type': 'Union[str, NoneType]'}, 'snowflake_schema': {'description': 'Override default schema', 'type': 'Union[str, NoneType]'}, 'timeout': {'description': 'Query timeout in seconds', 'type': 'Union[int, NoneType]'}} Tool Description: Execute SQL queries or semantic search on Snowflake data warehouse. Supports both raw SQL and natural language queries.

IMPORTANT: Use the following format in your response:

Thought: you should always think about what to do
Action: the action to take, only one name of [Snowflake Database Search], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action

Once all necessary information is gathered, return the following format:

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Agent: Data Analyst

Thought: Thought: I need to run the SQL query to obtain the current timestamp from the Snowflake database.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Thought: Thought: I need to execute the SQL query that retrieves the current time from the Snowflake database with the right schema and database specifications.

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:

Tool Name: Snowflake Database Search Tool Arguments: {'query': {'description': 'SQL query or semantic search query to execute', 'type': 'str'}, 'database': {'description': 'Override default database', 'type': 'Union[str, NoneType]'}, 'snowflake_schema': {'description': 'Override default schema', 'type': 'Union[str, NoneType]'}, 'timeout': {'description': 'Query timeout in seconds', 'type': 'Union[int, NoneType]'}} Tool Description: Execute SQL queries or semantic search on Snowflake data warehouse. Supports both raw SQL and natural language queries.

IMPORTANT: Use the following format in your response:

Thought: you should always think about what to do
Action: the action to take, only one name of [Snowflake Database Search], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action

Once all necessary information is gathered, return the following format:

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Agent: Data Analyst

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Agent: Data Analyst

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:

Tool Name: Snowflake Database Search Tool Arguments: {'query': {'description': 'SQL query or semantic search query to execute', 'type': 'str'}, 'database': {'description': 'Override default database', 'type': 'Union[str, NoneType]'}, 'snowflake_schema': {'description': 'Override default schema', 'type': 'Union[str, NoneType]'}, 'timeout': {'description': 'Query timeout in seconds', 'type': 'Union[int, NoneType]'}} Tool Description: Execute SQL queries or semantic search on Snowflake data warehouse. Supports both raw SQL and natural language queries.

IMPORTANT: Use the following format in your response:

Thought: you should always think about what to do
Action: the action to take, only one name of [Snowflake Database Search], just the name, exactly as it's written.
Action Input: the input to the action, just a simple JSON object, enclosed in curly braces, using " to wrap keys and values.
Observation: the result of the action

Once all necessary information is gathered, return the following format:

Thought: I now know the final answer
Final Answer: the final answer to the original input question

Agent: Data Analyst

Using tool: Snowflake Database Search

Tool Input:

"{"query": "SELECT CURRENT_TIMESTAMP();", "database": "STR", "snowflake_schema": "PUBLIC", "timeout": 30}"

Tool Output:

I tried reusing the same input, I must stop using this action input. I'll try something else instead.

Maximum iterations reached. Requesting final answer.

Agent: Data Analyst

Final Answer:

Current time:: YYYY-MM-DD HH:MM:SS.ssssss (actual output from the executed SQL query would be inserted here)


(Note: The actual timestamp will depend on the execution of the SQL query in the Snowflake environment.)


### Possible Solution

Agent needs to pass params to Snowflakesearch tool

### Additional context

None

mbabu-driftwood avatar Mar 21 '25 12:03 mbabu-driftwood

Tried the fix, issue persists. Worrisome that I am not even seeing a connection being made to Snowflake on the snowflake console. Final output after applying the fix is:

Agent: Data Analyst

Final Answer:

Current time:: [Current Timestamp Result From Snowflake]

As you can see, issue remains

mbabu-driftwood avatar Mar 21 '25 13:03 mbabu-driftwood

async def _run in snowflake_search_tool.py is not getting invoked

mbabu-driftwood avatar Mar 21 '25 18:03 mbabu-driftwood

version 108 is not working fine with search tools. Its quite random, sometime works sometime dont. I downgraded to version 105 and noticed its fast and worked perfectly.

infiadi avatar Mar 30 '25 15:03 infiadi

Facing the same issue with the SnowflakeSearchTool. Downgrading didn't change anything. Any ideas/workarounds on how to get SnowflakeSearchTool to work?

aybbr avatar Apr 08 '25 15:04 aybbr

Facing the same issue with the SnowflakeSearchTool. Downgrading didn't change anything. Any ideas/workarounds on how to get SnowflakeSearchTool to work?

Hi @aybbr Are you facing the same issue as mentioned above?

Vidit-Ostwal avatar Apr 08 '25 16:04 Vidit-Ostwal

Facing the same issue with the SnowflakeSearchTool. Downgrading didn't change anything. Any ideas/workarounds on how to get SnowflakeSearchTool to work?

Hi @aybbr Are you facing the same issue as mentioned above?

Yes. Are you able to reproduce on your end too?

aybbr avatar Apr 08 '25 19:04 aybbr

@aybbr I was not able to reproduce yet. Do u have any insight about the issue? Can we share with us?

lucasgomide avatar Apr 09 '25 15:04 lucasgomide

I think the other issue you closed has some better insights, missing _run is there.

Vidit-Ostwal avatar Apr 09 '25 15:04 Vidit-Ostwal

@aybbr I was not able to reproduce yet. Do u have any insight about the issue? Can we share with us?

All insights documented here.

aybbr avatar Apr 09 '25 18:04 aybbr

@aybbr , @lucasgomide I think I understood this.

the _run is an abstract method in the snowflake_tool is a async method, which gets called by a sync run method in the base_tool class. I think this is the reason by it is not awaiting properly.

will raise a PR to resolve this.

Vidit-Ostwal avatar Apr 09 '25 19:04 Vidit-Ostwal

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar May 10 '25 12:05 github-actions[bot]

Any update

vedika9009 avatar May 29 '25 03:05 vedika9009

Any update

I think this has been fixed. Update the crewai library along with tools, and test it out.

Vidit-Ostwal avatar May 29 '25 04:05 Vidit-Ostwal

Any update

I think this has been fixed. Update the crewai library along with tools, and test it out.

same issue even after updating crew core and crew-tools library

vedika9009 avatar May 30 '25 04:05 vedika9009