Hello,
I would like to create a crew with two agents with the objective to use the tool FileWriterTool:
The first agent is the researcher that requests the AI model to ask a question about a topic and the second agent use the content generated by the first one to save the content in a document saved using the tool FileWriterTool.
The first agent works correctly and the output_file is correct providing a good result structured as defined in the task.
However, the second agent doesn’t work correctly. He reuses the content of the first task but doesn’t save it in a file thanks to the tool FileWriterTool
If I defined a output_file for the second task, he almost creates the markdown file if I remove ‘’’ at the start and at the end of the document
However, the objective is to save the file with the tool FileWriterTool and it doesn’t work
Could you please help me ?
Here is the the agents.yaml file
researcher:
role: >
{topic} Senior Data Researcher.
goal: >
Your goal is to find five most important trends about {topic}
backstory: >
you are an expert having more than 15 years of experience in market analysis, you are the most representative of all the experts analyst in the world
writer:
role: >
{topic} Senior Data Writer.
goal: >
Your goal is to save the content generated by the agent researcher in a file {topic}_{date}.md by using the tool FileWriterTool
backstory: >
you are an expert for saving a text in a file of the system using the tool FileWriterTool
Each agent uses Ollama that load the model deepseek-r1
Here is the tasks.yaml file
research_task:
description: >
As researcher, you need to write a document about five trends for a specific {topic} in markdown format.
expected_output: >
This document is structured into four sections:
-Create a title for the document related to {topic}
-Write a section per trend that explain the trends in minimum 20 lines
-Write a conclusion
-Put all the references related to the documents related to the different trends
output_file: test.md
agent: researcher
write_file_task:
description: >
Save the content generated by research_task in the file {topic}{date}.md by using the tool FileWriterTool()
context: [“research_task”]
expected_output: >
File {topic}{date}.md formatted in markdown saved using FileWriterTool()
agent: writer
In the crew.py, the agent writer is written like that
@agent
def writer(self) → Agent:
return Agent(
config=self.agents_config[‘writer’],
llm=self.ollama_llm,
tools = [FileWriterTool(result_as_answer=True)],
verbose=True
)
Forcing to have the result as an answer…
I used AgentOps to debug the problem and I observe that the content of the file is written in the terminal.
The message written in AgentOps could be interesting :
Here is the text:
Assistant:
Okay, so I need to save the content generated by research_task into a file called AI_LLMs_2025.md using the FileWriterTool(). Alright, let’s break this down.
First, I should figure out how to use the tool. From what I remember, the tool requires a filename, an optional directory, an overwrite flag, and the content itself. Looking at the context provided, the user wants the file named AI_LLMs_2025.md.
I don’t think they mentioned using a specific directory this time, so maybe the default is just the current directory. But to be safe, perhaps I should check if there’s a default or not. In the previous example given in the thought process, the user didn’t specify a filename without an extension and used “None”, which probably means no extension was added.
The content they provided is a detailed markdown document with five key trends about AI_LLMs, each followed by some text and references. Since it’s already well-structured, I should make sure to include that exact content when saving.
Now, considering the tool arguments: filename as ‘AI_LLMs_2025.md’, directory maybe as None or an empty string if not specified, overwrite set to either True or False depending on whether they want to overwrite an existing file or not. Since there’s no mention of wanting to skip overwrites, I’ll assume it’s okay to overwrite.
So putting this all together, the action should be to use FileWriterTool with these arguments: filename as AI_LLMs_2025.md, directory probably empty string (or None), overwrite maybe set to True if they want to proceed or False otherwise. Looking at the thought process again, in their example, they used ‘filename’ and ‘content’, but didn’t specify directory or overwrite.
I think for this task, it’s best not to change the filename with an extension, so keep the filename as is without adding .md or anything else. So the filename argument should be {‘filename’: ‘AI_LLMs_2025.md’}, and since they might want to write over any existing file, overwrite can be set to True.
Therefore, the action would be: File Writer Tool with input containing these arguments.
Final Answer:
The final answer is a complete markdown document saved as AI_LLMs_2025.md using the FileWriterTool(). The content includes detailed information on five key trends in AI Large Language Models (AI_LLMs), each followed by specific text and references.
But the content is written in the terminal not in a file …
Thanks in advance for your support …