ReAct/Reasoning Agent¶
ReAct and Reasoning Agents are similar to function calling agents but with additional reasoning. They justify which tool to use with some prerequisite reasoning to help correctly identify the tool to use and run.
Each tool selection is followed by another iteration to see if the agent reasons to select another tool or is ready to answer.
Pros:
-
Reasoning augmented tool calling can improve accuracy on non-reasoning approaches.
-
Iterative tool loading can improve on agent accuracy for longer trajectory based problems.
Cons:
-
Reasoning requires additional token outputs which can contribute to inference time and dollar token costs.
-
ReAct and reasoning patterns may require custom response parsing which can require model specific code.
When to use:
This approach is effective and extends upon the simple function calling approach we introduced before, but requires the model to have been fine-tuned on reasoning and tool calling.
This approach is suitable for scenarios that have a small to medium list of tools and the use cases for that agent are targeted to a domain.
Accompanying this approach with ToolRAG can enable the extension of this agent to work with more tools and more generic utterances.
Prerequisites¶
This lab is a Jupyter notebook. Please follow the instructions in pre-work to run the lab.
Lab¶
To run the notebook from your command line in Jupyter using the active virtual environment from the pre-work, run:
jupyter notebook notebooks/ReAct_Agent.ipynb
The path of the notebook file above is relative to the granite-agent-workshop folder from the git clone in the pre-work.