Skip to main content
Original Author(s): Kristopher Overholt

Google Colab

colab.research.google.com
This tutorial demonstrates how to build, deploy, and trace a product recommendation agent using Google’s Agent Engine with LangGraph. You’ll learn how to combine LangGraph’s workflow orchestration with the scalability of Vertex AI to create a custom generative AI application that can provide product details and recommendations. You will:
  • Build a product recommendation agent using LangGraph and Google’s Agent Engine
  • Define custom tools for product information retrieval
  • Deploy the agent to Vertex AI for scalable execution
  • Instrument the agent with Phoenix for comprehensive tracing
By the end of this tutorial, you’ll have the skills and knowledge to build and deploy your own custom generative AI applications using LangGraph, Agent Engine, and Vertex AI

Notebook Walkthrough

We will go through key code snippets on this page. To follow the full tutorial, check out the notebook above.

Define Product Recommendation Tools

Create custom Python functions that act as tools your AI agent can use to provide product information.

Define Router Logic

Set up routing logic to control conversation flow and tool selection based on user input.

Build the LangGraph Application

Define your LangGraph application as a custom template in Agent Engine with Phoenix instrumentation.

Test the Agent Locally

Test your LangGraph app locally before deployment to ensure it behaves as expected.

Deploy to Agent Engine

Deploy your LangGraph application to Agent Engine for scalable execution and remote access.

Test the Deployed Agent

Test your deployed agent in the remote environment to verify it works correctly in production.

Inspect Traces in Phoenix

After running your agent, you can inspect the trace data in Phoenix to understand:
  • How the agent processes user queries
  • Which tools are called and when
  • The reasoning process behind tool selection
  • Performance metrics and latency
  • The complete conversation flow from query to response
The trace data will show you the complete flow of the product recommendation agent, from initial query processing to final response generation, giving you insights into the agent’s decision-making process.

Clean Up Resources

After you’ve finished experimenting, clean up your cloud resources to avoid unexpected charges.

Next Steps

As next steps, you can:
  • Expand the agent’s capabilities by adding more product categories and tools
  • Implement more sophisticated routing logic for complex queries
  • Add evaluation metrics to measure the agent’s performance
  • Analyze the trace data to optimize the agent’s decision-making process
  • Extend the agent to handle multi-turn conversations and product comparisons