Home / News / Build an AI Agent with LangGraph

Build an AI Agent with LangGraph

Recently, Atomic has been running an AI Stay Conference — a three-day, Grand Rapids–based event where Atoms come together to learn, build, and connect. It’s part workshop, team jam, and part local adventure, allowing us to step out of the office and focus on honing our skills to build LLM-powered applications. The conference is designed to provide real-world experience in designing and building agentic, AI-powered systems, blending technical deep dives, collaborative building sessions, and local outings to keep things both productive and fun. During the second half of the conference, I teamed up with Meghan to build a simple AI-powered news aggregation agent using LangGraph.

What’s an Agent Anyways?

Before examining the news agent, let’s clarify what classical software, AI workflows, and AI agents are.

Classical software is deterministic, following strictly defined logical flows without the capability for dynamic adaptation. Decisions in classical software are explicitly programmed and fixed at runtime, and the software cannot autonomously learn, reason, or adapt without predefined guidance.

AI workflows consist of processes with predetermined steps, where decisions made by an LLM occur at specific, fixed points. Workflows work best for structured, predictable tasks that can be fully mapped out in advance but don’t quite fit into the classical software bucket. For example, a system that helps streamline the creation of helpdesk tickets in natural language.

AI agents, as Google defines them, are software systems that use AI to pursue goals and complete tasks on behalf of users. They demonstrate reasoning, planning, and memory, possessing a degree of autonomy to make decisions, learn, and adapt. AI agents use LLMs to select tools and actions dynamically. This autonomy is a double-edged sword: agents can be highly effective in unpredictable and evolving environments, but it also makes it challenging to consistently choose the right approach when tasked with open-ended problems.

Exploring the News Agent: LangGraph and Tavily Tools

LangGraph was our go-to framework at this conference due to its ecosystem of tools, like observability in LangSmith and its development Studio UI. The other tool we utilized for this news agent was Tavily, which provides webpage search, extract, and crawling tools via a simple API with a free tier that has proven quite generous in the buildout of this agent.

Here’s a quick overview of our LangGraph structure:

The Core Workflow

  • Agent Node: Determines the operation mode (daily briefing, fun fact, single-source summary) based on the user’s query. It will execute dynamically, choosing a tool or set of tools that achieves the user’s desired outcomes. It will summarize the results and stream the response back to the user.
  • Tool Node: Aggregates multiple Tavily tools for web crawling, website mapping, direct search, and content extraction.
  • Feedback Node: This node enables human-in-the-loop interactions using Agent Inbox, capturing and incorporating user preferences into memory to track their preferred sources of information and topics.

What Makes This an Agent

Let’s break down what makes this news agent an agent based on the definition of an agent I used before:

  • Pursue Goals: The agent autonomously selects among three clear, user-driven objectives: summarizing recent news, presenting quirky news facts, and generating targeted summaries from specific outlets. It decides the best mode to match each user’s request.
  • Complete Tasks: The agent independently executes multi-step tool calls. It can crawl sites, extract content, search the web, and deliver concise Markdown summaries with citations without a strict path of operations to run when a user message comes in.
  • Planning: The AI uses context-driven planning by dynamically interpreting user intent and selecting suitable strategies. It continuously adjusts its approach based on intermediate outcomes to gather at least five relevant articles. If initial methods fall short, the agent adaptively escalates to advanced search parameters or alternate tools, ensuring flexibility and effectiveness.
  • Memory: Leveraging human-in-the-loop feedback, the agent maintains persistent memory. It updates memory profiles using structured schemas, continuously adapting its searches and filtering to improve future results based on user input.

What Worked and What Didn’t

By the end of the weekend, after lots of manual testing, we found success and encountered a few challenges:

  • Successes:
    • The agent successfully delivered personalized news content based on user preferences and query intent.
    • Structured prompts effectively guided accurate preference updates.
    • The agent adapted approaches based on the user’s message and the quality of results from Tavily.
    • The memory schema design organized different preferences and prevented cross-contamination.
  • Challenges:
    • This agent was created to provide timely news updates based on your preferences. Sometimes, we found that the agent returned results from many years ago rather than recent ones. We could likely improve this by further adjusting the prompts to the agent.
    • Streamlit proved to be a great prototyping tool for putting a webpage in front of your LLM. We had issues integrating Streamlit, but most of them stemmed from vibe coding this in at the last minute, which resulted in memory and human-in-the-loop integration issues. These issues were likely solvable with more time and less use of AI as a crutch.

Go Explore

So there you have it—a simple news agent built using Langgraph and Tavily showcasing the power of AI systems to automate, make decisions, and adapt based on user preferences. Building this AI Agent was a way to dive deeper into building applications using LangGraph and LLMs. The complete code for this news agent is available on GitHub.

The post Build an AI Agent with LangGraph appeared first on Atomic Spin.

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *