How to pass tool input if we are using custom tool,and expected agent output is tool output

I’m trying to build a tool-based workflow using crewai where an agent fetches stock data via a custom tool I defined the tool correctly with args_schema, passed it to the agent, and provided inputs via tools_input.

The tool is recognized.
No errors are thrown.
But the tool is not actually executed during the crew.kickoff() run — it seems the agent isn’t invoking the tool at all.

Here’s how I defined the task:

Task(
    description="Fetch stock data and save as CSV.",
    expected_output="CSV files with stock history data.",
    agent=agentDataPipeline(),
    tools=[MyCustomTool(result_as_answer=True)],
    tools_input={
        "Stock Data Downloader Tool": {
            "company_names": ["AAPL", "MSFT", "TSLA"],
            "days": 15,
            "save_data": True
        }
    }
)

What I need:

  • A minimal working example where a custom tool is actually called during execution by passing tool input para/args
  • Any advice on prompt structure or configuration that forces the agent to use the tool.

Yes it is interesting the first time as all you need to do is point your Task at the tool. in the config and also in the copy of the task yaml.
I build a really simple tool for QDRant amongst others. Here is the example GitHub - yqup/crewai-qdrant: CrewAI tool to update qdrant

Think “How would I explain the tool to a smart intern” and this will then get you started.

You point the intern to the tool and Tools - CrewAI in the crew setup and then tell it in the yaml.. I hope this helps.

1 Like

Thank you @Tony_Wood for your response ,That example didn’t worked for me.But when i passed input details in backstory somehow it worked.I have tried the same method with other custom tools also,those also worked without any issues.Is it the right method,as i couldnt see any examples from documentation page.



inputs ={
    "company_names":["AAPL", "MSFT", "TSLA","AMZN","META"],
    "days":15,
    "save_data":True
}

# custom_tool = MyCustomTool(
#     company_names=["AAPL", "MSFT", "TSLA"],
#     days=15,
#     save_data=True
# )
# custom_tool = MyCustomTool()
def agentDataPipeline():
    return Agent(
        role="Data Extractor ",
        goal="Fetch stock data and save as CSV",
        backstory=f"""You are responsible for fetching data based on {inputs}.""",
        verbose=True,
        llm=llm,
        allow_delegation=False,
        # tools = [custom_tool],
        tools = [MyCustomTool()],
    )
def data_task():
    return Task(
        description="Fetch stock data and save as CSV.",
        expected_output="CSV files with stock history data.",
        agent=agentDataPipeline(),
        # tools = [custom_tool],
       
        
    )



oh I see something that might help.

Tools are defined in the Task and not in the Agent.
Also try adding to the task description "Fetch stock data and save as CSV using the MyCustomTool"

Here is an example

   @agent
    def read_releases(self) -> Agent:
        return Agent(
            config=self.agents_config['read_releases'],
            verbose=False
        )

    @task
    def read_releases_task(self) -> Task:
        return Task(
            config=self.tasks_config['read_releases_task'],
            #output_file='releases.md',
            tools=[SerperDevTool(), ScrapeWebsiteTool()]
        )