How to obtain the output results of the agent, such as the name of the called tool, tool input parameters, etc

Hi, everyone
I want to get the intermediate results of the agent execution process, such as the results of ‘Using tool’, ‘Tool Input’, and ‘Tool Output’ in the picture. Currently, only the result of ‘Final Answer’ can be returned.

@maxmoura Could you help me answer this?

If you exactly want the tool output as the final answer, use ‘result_as_answer=True’ as follows:
tools = [MyCustomTool(result_as_answer=True]
Refer to documentation Force Tool Output as Result

I had a similar issue earlier. If our instructions are not great(description, expected output), even though our tool is capable, these kinds of variations in results will arise sometimes.

I’m trying to use the result_as_answer parameter for my crew like this:

@tool("scientific_serach")
def scientific_serach(query: str) -> str:
    """
    Performs a scientific search based on the provided query.

    Args:
        query (str): The scientific search query string to use for retrieving information.

    Returns:
        str: The result of the scientific search as a string.
    """
    return Utils().search_pubmed(query)

@agent
def research_executor_agent(self) -> Agent:
    return Agent(
        config=self.agents_config["research_executor_agent"],
        tools=[self.scientific_serach(result_as_answer=True)],
    )

but I’m getting this error

Traceback (most recent call last):
  File "C:\Users\s.russo\Documents\Knowlian\flow.py", line 81, in <module>                                                                                                                                        
    AssistantFlow().kickoff(inputs=input)                                                                                                                                                                         
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\flow\flow.py", line 722, in kickoff                                                                                                    
    return asyncio.run(run_flow())                                                                                                                                                                                
           ^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 190, in run                                                                
    return runner.run(main)
           ^^^^^^^^^^^^^^^^                                                                                                                                                                                       
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 118, in run                                                                
    return self._loop.run_until_complete(task)                                                                                                                                                                    
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                    
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 654, in run_until_complete                                             
    return future.result()                                                                                                                                                                                        
           ^^^^^^^^^^^^^^^                                                                                                                                                                                        
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\flow\flow.py", line 720, in run_flow                                                                                                   
    return await self.kickoff_async(inputs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                       
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\flow\flow.py", line 787, in kickoff_async                                                                                              
    await asyncio.gather(*tasks)                                                                                                                                                                                  
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\flow\flow.py", line 820, in _execute_start_method                                                                                      
    result = await self._execute_method(                                                                                                                                                                          
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                          
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\flow\flow.py", line 876, in _execute_method                                                                                            
    raise e
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\flow\flow.py", line 846, in _execute_method                                                                                            
    else method(*args, **kwargs)                                                                                                                                                                                  
         ^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                  
  File "C:\Users\s.russo\Documents\Knowlian\flow.py", line 18, in start_research_crew                                                                                                                             
    raa = ResearchAssistantCrew()                                                                                                                                                                                 
          ^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                 
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\project\crew_base.py", line 37, in __init__
    self.map_all_task_variables()                                                                                                                                                                                 
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\project\crew_base.py", line 234, in map_all_task_variables                                                                             
    self._map_task_variables(                                                                                                                                                                                     
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\project\crew_base.py", line 267, in _map_task_variables                                                                                
    self.tasks_config[task_name]["agent"] = agents[agent_name]()                                                                                                                                                  
                                            ^^^^^^^^^^^^^^^^^^^^                                                                                                                                                  
  File "C:\Users\s.russo\Documents\Knowlian\.venv\Lib\site-packages\crewai\project\utils.py", line 11, in memoized_func                                                                                           
    cache[key] = func(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\s.russo\Documents\Knowlian\research_assistant_crew\research_assistant_crew.py", line 52, in research_executor_agent
    tools=[self.scientific_serach(result_as_answer=True)],
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'Tool' object is not callable

Is there someone that had same issue?