crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
20.9k stars 2.9k forks source link

Multiple file read tools provide same content #319

Closed LarsAC closed 2 months ago

LarsAC commented 8 months ago

Hello,

I have tried to set up a crew where one agent / task uses two FileReadTools with different file arguments:

file1_tool = FileReadTool(file_path="./file1.json")
file2_tool = FileReadTool(file_path="./file2.txt")

[...]

researcher = Agent(
    role='Researcher',
    goal='You research interesting projects in the automotive industry.',
    backstory="You work as freelancer and write for magazines.",
    verbose = True,
    tools = [file1_tool, file2_tool],
)

[...]

research_task = Task(
  description="""Find out facts about interesting projects in the automotive industry.""",
  expected_output="""A description of a project developing new cars.""",
  agent = researcher,
  tools = [file1_tool, file2_tool]
)

However, execution of the crew runs into a message, that the two files have the same content, but in fact they are different:

Thought: 
The second file contains the exact same data as the first file. This means that I don't have additional information about the project's goals, innovations, and potential impact on the industry. However, based on the information available, I can still provide a basic overview of the project.

Is this a bug or anything I need to modify on my end to use contents of two files in the same task / agent ?

Lars

gadgethome commented 8 months ago

Could you try the tool DirectoryReadTool

This will allow the agent with this tool to read only the directory specified during it's execution tool = DirectoryReadTool(directory='./directory')

LarsAC commented 8 months ago

That does not seem to do what I want:


Action 'Read file' don't exist, these are the only available Actions: List files in directory: List files in directory() - A tool that can be used to list ./testdocs's content.

Thought: 
Given that I only have the 'List files in directory' tool available and not a 'Read file' tool, I am unable to provide detailed, specific information about a new project in the automotive industry. However, I can provide a general structure for the article based on my experience and expertise in the field. 
yshean commented 8 months ago

I encountered the same problem. Different files but same output by the FileReadTool, even though by manual inspection they have a completely different content.

Here is a response when attempting to read three different files:

[DEBUG]: Working Agent: Writer
[INFO]: Starting Task: Check if you have received feedback on the previous writing in feedback.txt, and then check if you have a previous writing in article.txt. If there is feedback, update the content in article.txt with the provided feedback. Otherwise, write an engaging and informative article based on the provided research report. Remember to cite your sources using the links provided in the report.

> Entering new CrewAgentExecutor chain...
Action: Read a file's content
Action Input: {"filename": "./article-materials/feedback.txt"} 

No feedback here yet.

Thought: Since there's no feedback available in the feedback.txt file, my next step is to check if there's a previous writing in article.txt before I proceed to write a new article based on the provided research report.
Action: Read a file's content
Action Input: {"filename": "./article-materials/article.txt"} 

No feedback here yet.

Thought: With no feedback in feedback.txt and a clarification that there is no previous writing in article.txt (as it mirrors the response in feedback.txt), the task is to write an engaging and informative article based on the provided research report. First, I need to read the content of the research findings to understand the details to be included in the article.
Action: Read a file's content
Action Input: {"filename": "./article-materials/research_findings.txt"} 

No feedback here yet.

You can see the output here all shows the content of feedback.txt and not other files.

amir-the-java-positive commented 6 months ago

we have encountered same issue. any plans when will it be fixed?

theCyberTech commented 6 months ago

Why are you assign the two tasks to the same agent? Why not assign to an agent each?

yshean commented 6 months ago

Why are you assign the two tasks to the same agent? Why not assign to an agent each?

What do you mean? There is only one task for each agent, but an agent could access multiple tools (in this case, two file read tools, one for each file)

theCyberTech commented 6 months ago

Sorry I meant tools, so for example each tool gets assigned to its own agent

amir-the-java-positive commented 6 months ago

is there any limit or problem if you assign more than one (fileread) tools in one agent ? to my knowledge, agents to tool mapping is not 1:1 or is it?
Thanks for your clarification in advance.

alexfazio commented 6 months ago

Hello. I am experiencing the same problem with the DirectoryReadTool.

> Entering new CrewAgentExecutor chain...
From these variables, it seems like my task is to return the name of all the folders within the directory "output-files". For this, I can use the "List files in directory" tool.

Action: List files in directory
Action Input: {"directory": "./output-files"} 

File paths: 
-

Thought: 
From the above observations, it seems that I am not allowed to use the tool to achieve the task. Without using the tool, I'm unable to gather the information needed to complete the task as I can't list the files in the directory. 

Final Answer: 
Unable to provide the final answer because the tool needed to perform the task is not allowed to be used.

Check this notebook to reproduce the error. https://colab.research.google.com/drive/1BvUQfXcr-gw-We07xRNpuqF0PgOr0eoP?usp=sharing

alexfazio commented 6 months ago

I just tested this in version 0.30.0rc3 and it still has problems.

Refer to this notebook for a quick reproduction of the issue: https://colab.research.google.com/drive/1BvUQfXcr-gw-We07xRNpuqF0PgOr0eoP?usp=sharing

felixgao commented 5 months ago

I am still seeing the same problem in 0.30.11 Is there a fix or workaround?

AdelDima commented 4 months ago

1- Use FileReadTool without any parameters and send it to the agent. 2- on the agent goal add the files that you want to read like this

goal=f"""
Understand files. from
{path_storyline_01} and {path_toryline_02}
""",
github-actions[bot] commented 2 months ago

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] commented 2 months ago

This issue was closed because it has been stalled for 5 days with no activity.

ricardolousada commented 1 month ago

I don't understand how can the issue be close without being solved....I have just used the last versions and have exactly the same problem!?

ricardolousada commented 1 month ago

1- Use FileReadTool without any parameters and send it to the agent. 2- on the agent goal add the files that you want to read like this

goal=f"""
Understand files. from
{path_storyline_01} and {path_toryline_02}
""",

Imagine you have 20 or more files, this is crazy.....

akshay-rakheja commented 1 month ago

1- Use FileReadTool without any parameters and send it to the agent. 2- on the agent goal add the files that you want to read like this

goal=f"""
Understand files. from
{path_storyline_01} and {path_toryline_02}
""",

This worked for me. Thank you.