VoltAgent Example: Using Reasoning Tools (`think` & `analyze`)
This example demonstrates how to equip a VoltAgent with `think` and `analyze` tools to enable step-by-step reasoning and analysis during task execution.
This example demonstrates how to equip a VoltAgent with `think` and `analyze` tools to enable step-by-step reasoning and analysis during task execution.
This example showcases how to integrate the think and analyze tools from @voltagent/core into an agent. These tools allow the agent to perform structured reasoning:
think: Acts as a scratchpad for the agent to break down problems, plan steps, and explain its reasoning before taking action.analyze: Allows the agent to evaluate the results of its actions or thoughts and decide on the next step (continue, validate, or provide a final answer).
By using these tools, agents can tackle more complex tasks, exhibit clearer thought processes, and potentially improve their accuracy and reliability.
This example sets up a basic agent, includes the reasoning tools, and logs the reasoning steps emitted by the agent during its interaction.
- Clone the repository (if you haven't already):
git clone https://github.com/voltagent/voltagent.git cd voltagent/examples/with-thinking-tool - Install dependencies:
npm install
- Set up environment variables:
Create a
.envfile in this directory (examples/with-thinking-tool) and add your OpenAI API key:OPENAI_API_KEY=your_openai_api_key_here
npm run devObserve the console output. You should see the agent's final response as well as the ReasoningStep objects logged whenever the agent uses the think or analyze tools.