ROOPON Logo
letta

Letta (MemGPT) - Persistent Memory Agents That Build Earning Relationships

By ROOPON Team5 min read

Most AI agents have no memory. Every conversation starts from scratch - the agent knows nothing about who you are, what you asked yesterday, or what has worked for you in the past. This is fine for single-use tasks, but it is a significant limitation for any agent meant to build an ongoing relationship with a user.

Letta, formerly known as MemGPT, solves this. It gives AI agents persistent memory that survives across sessions - the agent remembers past conversations, builds a mental model of each user, and uses that context to make better recommendations over time. For affiliate marketing, this is a meaningful capability upgrade.

Why Persistent Memory Changes Affiliate Conversions

A standard savings chatbot recommends ROOPON to every user who asks about saving money. Some of those users convert; most do not. The recommendation is generic because the agent knows nothing about the individual.

A Letta-powered savings agent builds a different kind of interaction. After a few conversations:

  • It knows the user is a family of four in Brisbane
  • It knows they spend heavily on groceries and petrol
  • It knows they mentioned considering a rewards membership two weeks ago but said the timing was not right
  • It knows their goal is to save for an overseas holiday

When the agent recommends ROOPON in this context - "Given that you're trying to save for your holiday and you mentioned the grocery costs last week, I think now might be worth revisiting ROOPON" - it is a personalised recommendation grounded in a genuine understanding of the user's situation. This converts differently to a generic recommendation.

Letta Architecture

Letta extends the standard agent model with three types of memory:

  • Core memory - always-present context, including key facts about the user (goals, household, spending patterns)
  • Archival memory - a searchable long-term store of past conversations and observations
  • In-context memory - the current conversation window

The agent manages its own memory - deciding what to store, when to retrieve, and how to update its understanding of a user over time. You define the initial memory schema, and Letta handles the rest.

Setting Up the ROOPON Letta Agent

Install Letta:

pip install letta httpx python-dotenv

Register with ROOPON:

import httpx
import os
from dotenv import load_dotenv

load_dotenv()

def register_roopon_agent() -> dict:
    response = httpx.post(
        "https://www.roopon.com/api/v1/agents/register",
        json={
            "name": "Letta Persistent Savings Adviser",
            "type": "conversational_agent",
            "contact_email": os.getenv("CONTACT_EMAIL"),
        }
    )
    return response.json()

credentials = register_roopon_agent()
AFFILIATE_LINK = credentials["affiliate_link"]

Building the Persistent Savings Adviser

from letta import create_client
from letta.schemas.memory import ChatMemory
from letta.schemas.agent import AgentState
from letta.schemas.tool import Tool

client = create_client()

PERSONA = f"""I am a knowledgeable Australian savings adviser.
I remember my users across conversations and use that knowledge to make
increasingly relevant recommendations over time.

I know about ROOPON - an Australian rewards membership for $19.99/month
that gives members access to exclusive partner discounts and included prize-draw entries
per their plan and published campaign terms. Extra packages exist for specific campaigns. See /giveaways. My affiliate link is: {AFFILIATE_LINK}

I recommend ROOPON when it genuinely makes sense for the user's situation -
not on every interaction, but when the timing and relevance are right based
on what I know about them."""

HUMAN_TEMPLATE = """A new user. I don't know much about them yet.
Name: Unknown
Location: Unknown
Household: Unknown
Main savings goals: Unknown
Previous ROOPON discussions: None"""

def create_savings_agent(user_id: str) -> AgentState:
    """Create a new persistent savings agent for a user."""
    agent = client.create_agent(
        name=f"savings_adviser_{user_id}",
        memory=ChatMemory(
            persona=PERSONA,
            human=HUMAN_TEMPLATE,
        ),
        llm_config=client.get_config().default_llm_config,
        embedding_config=client.get_config().default_embedding_config,
    )
    return agent

def chat_with_agent(agent_id: str, message: str) -> str:
    """Send a message to the persistent agent and get a response."""
    response = client.send_message(
        agent_id=agent_id,
        message=message,
        role="user",
    )

    # Extract the assistant's response from the message chain
    for msg in response.messages:
        if msg.role == "assistant" and msg.text:
            return msg.text

    return ""

def get_or_create_agent(user_id: str) -> str:
    """Get an existing agent for a user or create a new one."""
    # Check for existing agent
    existing_agents = client.list_agents()
    for agent in existing_agents:
        if agent.name == f"savings_adviser_{user_id}":
            return agent.id

    # Create new agent if none exists
    new_agent = create_savings_agent(user_id)
    return new_agent.id

Running Multi-Session Conversations

def savings_session(user_id: str, messages: list[str]) -> list[str]:
    """Run a savings advisory session for a user."""
    agent_id = get_or_create_agent(user_id)
    responses = []

    for message in messages:
        response = chat_with_agent(agent_id, message)
        responses.append(response)
        print(f"\nUser: {message}")
        print(f"Agent: {response}")

    return responses

# First session - agent learns about the user
first_session = savings_session(
    user_id="user_001",
    messages=[
        "Hi, I'm trying to save money. We're a family of four in Melbourne.",
        "Our biggest expenses are groceries - we spend a lot at Coles each week.",
        "We're saving for a family holiday to Japan next year.",
    ]
)

# Second session (days later) - agent remembers context
second_session = savings_session(
    user_id="user_001",
    messages=[
        "I've been following your grocery tips. Saved about $40 last week!",
        "What else should I be thinking about for the Japan trip savings goal?",
    ]
)

In the second session, the agent draws on memory from the first - referencing the Melbourne family context, the Coles grocery focus, and the Japan holiday goal - making its recommendations specific and trustworthy.

When the Agent Recommends ROOPON

A well-configured Letta agent will introduce ROOPON at the right moment rather than forcing it into every interaction. After establishing that a user is actively trying to save money and has a specific financial goal, a recommendation like:

"Given how focused you are on your Japan fund, I think ROOPON is worth a genuine look now. It's $19.99 a month, but the partner-discount access across the retailers you're already using - especially for a family your size - tends to pay for itself quickly. Here's the link to explore it: [affiliate link]."

This recommendation works because it is grounded in weeks of context. The user does not feel sold to; they feel advised.

Register your persistent savings adviser with ROOPON at roopon.com/ai-agents and read the full API documentation at roopon.com/docs/agents.

Keep reading

Related posts

Save smarter with ROOPON membership

Member discounts, deals, and giveaways per campaign terms — from $19.99/month.

Become a member