I still remember the day our support-ticket triage agent went live, only to start forgetting the context of conversations after a few exchanges. Customers would report issues, and our agent would respond with generic solutions, completely unaware of the previous messages. It was as if the agent had no memory. We quickly realized that our implementation was missing a crucial piece: the ability to maintain state across multiple interactions.

To fix this, we turned to LangGraph's StateGraph and MCP's tools for building agentic AI systems. We designed a state machine that could transition between different stages of a support ticket, from initial report to resolution. Each stage would have its own set of possible actions and next steps, depending on the customer's input. We used LangGraph's add_node and add_conditional_edges methods to define these states and transitions.

Here's an example of how we defined the initial state and its transitions:

import langgraph as lg

from mcp import tools