AI Agents with Memory

⏱️ Time to Complete: 15 minutes 🎯 Level: Intermediate πŸ’» Language: TypeScript

What You'll Build

An AI agent that:

  • βœ… Maintains conversation history across sessions

  • βœ… Searches your knowledge base semantically

  • βœ… Uses tools to accomplish tasks

  • βœ… Reasons across multiple data sources

  • βœ… Streams responses in real-time

πŸ“ Tool calling examples | πŸš€ Production example: Zine


Why Agents Need Memory

Traditional chatbots forget everything between sessions. AI agents with semantic memory:

  • βœ… Remember past conversations and decisions

  • βœ… Search across all your company's knowledge

  • βœ… Use tools to take actions (not just answer questions)

  • βœ… Reason across multiple data sources

  • βœ… Share context with other agents

Real-world example: Zine uses this pattern to let agents search Slack threads, meeting transcripts, and GitHub discussions simultaneously.


Prerequisites

Need Python or .NET versions? Open Ask Graphlit from the Developer Portal sidebar (or visit ask.graphlit.dev) for autogenerated samples in any SDK.


Pattern 1: Multi-Turn Conversations with Memory

First, create an agent that keeps track of everything you've asked it:

What's happening:

  • Agent automatically retrieves relevant context from its memory

  • Conversation state persists across turns (follow-up questions work)

  • You can inspect the full conversation history after each exchange


Pattern 2: Agentic Tool Calling

Let your agent call custom tools instead of just responding with text:

What's happening:

  • Agent sees the available tool definitions and selects the right one

  • Tool calls are recorded on the conversation so you can execute them

  • Responses combine tool outputs with natural language answers

Real-world example: Zine uses this pattern for questions like β€œWhy are checkout timeouts spiking?” β€” the agent queries Sentry, Slack, GitHub, and meeting notes via tools.


Pattern 3: Multi-Agent Systems with Shared Knowledge

Point multiple agents at the same semantic memory but give each its own persona:

What's happening:

  • Two agents share the same knowledge base but have different prompts and temperatures

  • Retrieval strategy keeps both agents grounded in the same set of documents

  • You can orchestrate the agents together (sales β†’ engineering handoff) without duplicating memory


Pattern 4: Streaming Responses

For real-time user experiences, stream agent output as it happens:

Use cases:

  • Real-time chat experiences (Graphlit + Next.js chat app)

  • Live meeting transcription with incremental summaries

  • Progressive document generation or approvals


Production Patterns

Error Handling

Rate Limiting

Context Management


Real-World Examples

1. Customer Support Agent

  • Searches past tickets, product docs, and conversations

  • Maintains conversation history per customer

  • Uses tools to create tickets, update CRM

2. Engineering Agent (like Zine)

  • Searches Slack, GitHub, Jira simultaneously

  • Reasons across code, discussions, and meeting notes

  • Uses tools to fetch error logs, run queries

3. Sales Agent

  • Searches customer conversations, contracts, meeting notes

  • Tracks deal status and objections

  • Uses tools to update CRM, send follow-ups


Next Steps


Full Example: Production Agent

See the complete Next.js agent in graphlit-samples:

  • Tool calling with streaming UI

  • Shared collections and semantic memory queries

  • Production-ready configuration (environment variables, error handling)


Build agents that actually remember. Build with Graphlit.

Last updated

Was this helpful?