LangChain Conversational Agent - Coursework Foundations
A two-iteration coursework chatbot built with LangChain v1's create_agent API, evolving from a single-shot LLM call to a stateful CLI loop with multi-turn memory.
Business Problem
Coursework framing rather than a market problem. The AI Principles assignment was to build foundational fluency with LangChain's agent abstraction and Gemini integration, since these are the building blocks for the more complex agentic systems used in industry (and reused in larger projects on this portfolio).
Tools Used
Key Features
- v1: single-shot agent invocation answering one user question end-to-end
- v2: multi-turn CLI chatbot that manually maintains conversation history across turns
- Gemini 2.5 Flash wired in via the langchain-google-genai integration
- Reusable system prompt ('clear, concise, polite, professional, safe') focused on agent mechanics rather than prompt engineering
- dotenv-based API key management to keep secrets out of source
- Graceful exit on 'bye' or 'exit' input, with try/except around reply extraction so the loop never crashes silently on an unexpected response shape
My Role & Contribution
Sole student author. Designed the v1 to v2 progression to make the stateful-conversation pattern visible, kept scope intentionally minimal, and matched the dependency stack to what's used in the larger AI projects on this portfolio.
Biggest Challenge
Managing conversational state when the agent itself is stateless per invocation. Solved by building a list-of-messages history that gets concatenated with each new user input and passed back into agent.invoke({'messages': ...}) - the canonical pattern for stateful agents in the new LangChain API. Aligning the dependency matrix (langchain, langchain-core, langgraph, langchain-google-genai) without version conflicts was a close second.
What I Learned
When to use the agent abstraction over a direct LLM call (you reach for it as soon as you need tools or multi-step reasoning) and how to manage chat history outside the agent. The v1 to v2 progression - single-shot call evolving into a stateful loop - is exactly the mental model needed before adding tools, memory, and orchestration. Same patterns scale up to the production multi-agent work in Handyman Ops Desk and the Gemini Virtual Assistant on this portfolio.