Building AI Agents With Long-Term Memory
We give AI agents persistent memory by storing their state and conversation history in a PostgreSQL database. This state is managed by a custom state machine, allowing agents to resume multi-step tasks across sessions.
Key Takeaways
- Syntora gives AI agents persistent memory by storing conversational state and workflow progress in a Supabase PostgreSQL database.
- Custom state machines, often built with LangGraph, allow agents to pause and resume complex tasks over hours or days.
- This architecture enables multi-step workflows like document processing or lead qualification that require human-in-the-loop approvals.
- Retrieving an agent's state from the database typically takes less than 150 milliseconds, ensuring a responsive user experience.
Syntora builds multi-agent systems with persistent memory using Supabase and custom Python state machines. An agent can pause a workflow, wait for human input for over 24 hours, and then resume with full context. This system enables complex, long-running automations like document processing and multi-day lead qualification.
The complexity of an agent's memory depends on the workflow's duration and the number of required state transitions. A simple lead qualification agent might have 5 states, while a document processing system with human-in-the-loop approvals could have over 20. For Syntora's own operations, we built a multi-agent orchestrator that uses this persistence pattern to route tasks between specialized agents without losing context.
The Problem
Why Do Standard AI Chatbots Forget Everything?
Many businesses experiment with AI agents using platforms that rely solely on the LLM's context window for memory. This works for single-turn Q&A but fails for any real business process. The context window is a temporary scratchpad, not a durable memory. When a workflow needs to pause for human input or an external event, that context is lost forever, forcing the process to restart from zero.
Consider a 5-person logistics company using an AI agent to process inbound shipping manifests. The agent must extract items from a 20-page PDF, check inventory for 30+ line items against an external API, and flag discrepancies for a manager. The manager might not review the flagged items for 12 hours. A standard agent, having finished its initial API calls, has its state wiped. When the manager finally sends an approval message, the agent has no memory of the original PDF or which items were flagged. The entire 30-minute process must be run again.
The structural problem is that most agent-building tools treat memory as a cache. They lack a transactional state management layer. Using a simple key-value store like Redis is a common first step, but it is insufficient for complex workflows. Redis can store the last message, but it cannot easily represent a branching process, store a full audit history, or allow for querying the agent's past decisions. A business-critical process requires a true database acting as the agent's long-term memory.
Our Approach
How Syntora Builds Persistent Memory with Supabase and State Machines
The first step is to map your complete business process into a finite state machine. We diagram every possible state the agent can be in ('awaiting_document', 'extracting_data', 'awaiting_human_approval', 'generating_report'). This map defines the database schema and becomes the blueprint for the agent's logic. You see exactly what the agent will remember, and when, before any code is written.
The technical approach uses Supabase, a managed PostgreSQL service, as the agent's durable memory. Each task is a row in a database table with a `state` column. We use Python with LangGraph to define the state transitions. A lightweight FastAPI service, deployed on DigitalOcean App Platform, acts as the agent's brain. When a webhook arrives (e.g., an approval from a Slack message), the service loads the task's state from Supabase, executes the next step using the Claude API, and updates the state in the database. This entire state retrieval and update cycle completes in about 200 milliseconds.
The delivered system is a containerized application that you own completely. Your team interacts with the agent through existing tools like email or Slack, with no new software to learn. The agent's memory lives in your own Supabase instance, giving you a full audit trail of every decision made. The source code and a runbook are stored in your GitHub repository, so you have full control to modify or extend the system.
| Stateless Agent (Context Window Memory) | Persistent Agent (Database Memory) |
|---|---|
| Workflow is limited to a single session lasting minutes. | Workflow can span multiple days or weeks. |
| High cost to resume. Must re-send entire history, consuming thousands of tokens. | Low cost to resume. Loads state from a database in under 150ms. |
| Fails on server restart or if a user closes the browser. | Survives system restarts and resumes via webhook triggers. |
Why It Matters
Key Benefits
One Engineer From Call to Code
The person on the discovery call is the person who architects your state machine and writes the production Python code. No handoffs, no miscommunication.
You Own The Agent's Brain
You receive the full source code, database schema, and deployment runbook. There is no vendor lock-in on your agent's core memory or decision-making logic.
Production-Ready in Under 4 Weeks
A typical multi-agent system with persistence is scoped, built, and deployed in about four weeks, depending on the number of integrations.
Transparent Post-Launch Support
Optional monthly retainer for monitoring, database maintenance, and agent logic updates. The cost is fixed and predictable. Cancel anytime.
Built for Asynchronous Business
Syntora's architecture is designed for real-world processes that involve delays and human approvals. The system is built to handle workflows that span hours or days.
How We Deliver
The Process
Workflow Mapping Session
A 60-minute call to diagram your process from start to finish. We identify every step, data source, and decision point. You receive a formal state diagram and a fixed-price scope document.
Architecture and Schema Design
We present the proposed database schema and state machine logic for your approval. You see exactly how the agent will store and retrieve information before the build begins.
Build and Integration Sprints
You get access to a private channel for updates and bi-weekly demos of the working agent. We integrate with your tools like Slack, email, or internal APIs, getting your feedback along the way.
Handoff and Documentation
You receive the complete source code in your GitHub, a runbook for deployment and maintenance, and a 2-week post-launch support period to ensure a smooth transition.
Keep Exploring
Related Solutions
The Syntora Advantage
Not all AI partners are built the same.
Other Agencies
Assessment phase is often skipped or abbreviated
Syntora
We assess your business before we build anything
Other Agencies
Typically built on shared, third-party platforms
Syntora
Fully private systems. Your data never leaves your environment
Other Agencies
May require new software purchases or migrations
Syntora
Zero disruption to your existing tools and workflows
Other Agencies
Training and ongoing support are usually extra
Syntora
Full training included. Your team hits the ground running from day one
Other Agencies
Code and data often stay on the vendor's platform
Syntora
You own everything we build. The systems, the data, all of it. No lock-in
Get Started
Ready to Automate Your Technology Operations?
Book a call to discuss how we can implement ai automation for your technology business.
FAQ
