Skip to main content
By combining reasoning and tool execution, we can construct a ReAct Agent that runs in a loop to solve problems. This page covers building a complete working agent project.

1. The Modern LangChain Agent Stack

To build agents in modern LangChain, we use LangGraph, which models agents as state graphs where the LLM decides node transitions (e.g. calling tools vs. returning the final response).

2. In-Memory Working Agent Project

Let’s build a working agent equipped with a math evaluation tool and a dictionary database look-up tool.

2.1 Install Dependencies

Run in your terminal:

2.2 Complete Code Implementation

Save and run this script:
Expected Trace Behavior:
  1. The agent notices "Find siva's email" and runs get_user_email(employee_name="siva").
  2. The agent notices "calculate 345 * 12" and runs calculate_math(expression="345 * 12").
  3. The agent merges both observations and outputs: “Siva’s email is [email protected] and 345 * 12 is 4140.”

3. Practice Exercises

Practice 1: Add a Currency Converter Tool

Extend the working agent by adding a new tool convert_usd_to_eur(amount: float) -> float that multiplies the USD amount by 0.92. Run the query: "Find siva's email and convert 150 USD to EUR." and print the output. Instructions:
  1. Write the convert_usd_to_eur tool.
  2. Add it to the tools list.
  3. Call create_react_agent(llm, tools).
  4. Invoke the agent and print the final message content.