Overview
LangGraph lets you build stateful, multi-step agent workflows as directed graphs. By integrating Lyzr Cognis as dedicated graph nodes, you can add persistent memory retrieval and storage as first-class steps in your agent pipeline. What you’ll build: A support chatbot with aretrieve → respond → store graph that automatically recalls customer history and persists new interactions.
Why Cognis + LangGraph? LangGraph excels at defining explicit control flow for agents. Cognis memory nodes slot naturally into this graph — giving you fine-grained control over when and how memory is retrieved, used, and stored.
Prerequisites
Quick Start
Complete Example: Support Chatbot
Step 1: Define the State
Step 2: Define Graph Nodes
Step 3: Add Conditional Edges
Skip storing trivial messages (greetings, single-word replies):Step 4: Build and Compile the Graph
Step 5: Run Conversations
Cognis Methods Reference
| Method | Description | When to Use |
|---|---|---|
cog.add(messages, owner_id, session_id, agent_id) | Store conversation messages | After each interaction |
cog.search(query, owner_id, limit) | Semantic search over memories | Before generating a response |
cog.get(owner_id, limit) | List all memories for a user | Displaying user profile |
cog.context(current_messages, owner_id, session_id) | Server-assembled context | When you want Cognis to manage context assembly |
cog.delete(memory_id, owner_id) | Remove a specific memory | User requests data deletion |
cog.update(memory_id, content) | Update a memory’s content | Correcting stored information |
Advanced Patterns
Using cog.context() in a Graph Node
Replace the manual search() + format step with Cognis server-side context assembly:
Async Graph Nodes
Use Cognis async methods for non-blocking graph execution:Cross-Session Memory
Enable cross-session search to recall interactions from previous support tickets:Next Steps
- Cognis + LangChain — Simpler LCEL chain integration
- Cognis + CrewAI — Add memory to multi-agent crews
- Cognis + Agno — Tool-based memory for autonomous agents
- Lyzr ADK Memory Documentation — Full Cognis API reference