Irregular Behavior of FileTools

from agno.tools.file import FileTools

toolset = [CalculatorTools(),YFinanceTools(enable_all=True),FileTools()]
agent = Agent(model=OpenAIChat(id="gpt-4o",api_key=os.environ["OPENAI_API_KEY"]),
              knowledge=knowledge_base,
              description=description,
              instructions=instructions,
              expected_output=expected_output,
              tools=toolset,
              tool_choice="auto",
              add_references=True,  # Turns on RAG mode
              search_knowledge=False,
              show_tool_calls=True)

response: RunResponse = agent.run("Provide a detailed report about the profit and expense? Save the answer to a markdown file named report.md.")

This does gives me desired output but it does not save the file. The Behavior is irregular because if i run the same command multiple times it does save one of the time. What could be the cause?

Hi
Thanks for reaching out and for using Agno! I’ve looped in the right engineers to help with your question. We usually respond within 24 hours, but if this is urgent, just let us know, and we’ll do our best to prioritize it.
Appreciate your patience—we’ll get back to you soon! :smile:

did you tried a python function/tool ?

Sorry but i didn’t quite understood what you’re asking. I didn’t use any custom tool using @tool decorator if that’s what you are asking. I used prebuilt tool from the catelogue.

Hey @shivamSingh!

I tried your code with a few minor modifications on my end:

from agno.tools.file import FileTools
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.calculator import CalculatorTools
from agno.tools.yfinance import YFinanceTools
from agno.run.response import RunResponse

toolset = [CalculatorTools(), YFinanceTools(enable_all=True), FileTools()]
agent = Agent(model=OpenAIChat(id="gpt-4o"),
              tools=toolset,
              show_tool_calls=True,
              debug_mode=True)

response: RunResponse = agent.run("Provide a detailed report about the TSLA stock? Save the answer to a markdown file named report.md.")

Each time I ran it, I successfully created a report.md file. Could you try enabling debug_mode=True in your agent to check if the function call to save the file is happening? Also, can you confirm whether the file is never created at all or if it occurs intermittently?

Let me know what you find. I’d be happy to help troubleshoot this further!