Agent Memory & Context

How thinnestAI agents remember information across conversations and maintain context within sessions.

Agent Memory & Context

Memory gives your agents the ability to remember information — both within a single conversation and across multiple interactions. A support agent that remembers a caller's name, a booking agent that recalls past appointments, or a sales agent that builds on previous conversations all rely on memory.

How Memory Works

thinnestAI provides two types of memory:

  1. Session Memory — Conversation history within a single call or chat session
  2. Agentic Memory — Long-term memory that persists across sessions, managed by the agent itself

Both work together to create a natural, contextual experience for your users.

Session Memory (Conversation History)

Session memory is automatic. Every message in a conversation — from both the user and the agent — is tracked and included as context for the agent's next response. This means your agent always knows what was said earlier in the current conversation.

How It Works

When a user says something, thinnestAI sends the full conversation history to the AI model along with the new message. The model sees everything that was said and responds in context.

For example, in a phone call:

Caller: "Hi, I'd like to check on my order."
Agent:  "Sure! Can I get your order number?"
Caller: "It's 45678."
Agent:  "Thanks. Order #45678 shipped yesterday and should arrive by Friday."
Caller: "What about my other order?"
Agent:  "Let me check. Do you have the order number for that one?"

The agent remembers the full conversation, so "my other order" makes sense in context.

Session Persistence

By default, each phone call or chat session is a separate conversation. When the session ends, the conversation history is saved and can be reviewed in Call Logs, but a new call starts fresh.

You can configure session persistence to link conversations:

  • Per Phone Number — If the same phone number calls again, the agent has access to the previous conversation history.
  • Per User — If the caller is identified (via phone number lookup or authentication), conversations are linked across all sessions.
  • Time Window — Only recall conversations from the last N days.

Configuring Session Persistence

In the dashboard, go to Agent Settings > Memory:

SettingOptionsDescription
Session Modeisolated, persistentWhether sessions are independent or linked
Lookup Byphone_number, user_id, emailHow to identify returning users
History Window1-90 daysHow far back to include past conversations
Max History Messages10-100Maximum number of past messages to include as context

Via the API:

curl -X PATCH https://api.thinnest.ai/agents/agent_abc123 \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "memory": {
      "session_mode": "persistent",
      "lookup_by": "phone_number",
      "history_window_days": 30,
      "max_history_messages": 50
    }
  }'

Agentic Memory

Agentic memory is a more advanced feature where the agent decides what to remember on its own. Instead of just replaying conversation history, the agent extracts and stores key facts, preferences, and context that it deems important.

How It Works

When agentic memory is enabled, the agent has access to a remember tool. During conversations, it can choose to save information it considers important:

Caller: "By the way, I prefer morning appointments. Before 10am if possible."
Agent:  [internally: stores "Prefers morning appointments, before 10am"]
Agent:  "Got it, I'll keep that in mind for future bookings."

--- Next call, weeks later ---

Caller: "I need to book a dental cleaning."
Agent:  [internally: recalls "Prefers morning appointments, before 10am"]
Agent:  "Sure! I see you prefer morning appointments. How about Tuesday at 9am?"

The agent learns and adapts over time without you needing to manually configure anything.

What Gets Remembered

The agent uses its judgment to decide what's worth remembering. Typically:

  • User preferences — Communication preferences, scheduling preferences, product preferences
  • Key facts — Name, account details, past issues
  • Context — Ongoing issues, recent interactions, follow-up items
  • Relationships — "This is John's assistant calling about his account"

Enabling Agentic Memory

In the dashboard, toggle Agentic Memory on in your agent's Memory settings.

Via the API:

curl -X PATCH https://api.thinnest.ai/agents/agent_abc123 \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "memory": {
      "agentic_memory": true
    }
  }'

Reviewing Stored Memories

You can view and manage what your agent has remembered:

  1. Go to Agent > Memory in the dashboard.
  2. Browse stored memories organized by user/phone number.
  3. Delete or edit individual memories if needed.

Via the API:

# List memories for a specific user
curl https://api.thinnest.ai/agents/agent_abc123/memory?phone=+14155551234 \
  -H "Authorization: Bearer $THINNESTAI_API_KEY"
{
  "memories": [
    {
      "id": "mem_001",
      "content": "Prefers morning appointments, before 10am",
      "created_at": "2026-02-15T09:30:00Z",
      "source_session": "session_xyz"
    },
    {
      "id": "mem_002",
      "content": "Has two children, ages 8 and 12, who are also patients",
      "created_at": "2026-02-20T14:00:00Z",
      "source_session": "session_abc"
    }
  ]
}

Memory and Token Usage

Memory adds context to each request, which increases token usage. Here's how to manage it:

Session History

More history means more tokens per request. If you're on a budget:

  • Reduce max_history_messages to 10-20
  • Shorten history_window_days
  • Use a model with a large context window (like Gemini) if you need long history

Agentic Memory

Stored memories are typically short summaries, so they add minimal token overhead. However, an agent with hundreds of memories for a single user will use more tokens.

Recommendations

Use CaseSession ModeAgentic MemoryHistory Messages
One-off support callsisolatedOffN/A
Repeat customer supportpersistentOn20-30
Appointment bookingpersistentOn10-20
Sales / lead qualificationpersistentOn30-50
SurveysisolatedOffN/A

Clearing Memory

Clear Session History

# Delete all session history for an agent
curl -X DELETE https://api.thinnest.ai/agents/agent_abc123/sessions \
  -H "Authorization: Bearer $THINNESTAI_API_KEY"

# Delete a specific session
curl -X DELETE https://api.thinnest.ai/agents/agent_abc123/sessions/session_xyz \
  -H "Authorization: Bearer $THINNESTAI_API_KEY"

Clear Agentic Memories

# Delete all memories for a user
curl -X DELETE https://api.thinnest.ai/agents/agent_abc123/memory?phone=+14155551234 \
  -H "Authorization: Bearer $THINNESTAI_API_KEY"

# Delete a specific memory
curl -X DELETE https://api.thinnest.ai/agents/agent_abc123/memory/mem_001 \
  -H "Authorization: Bearer $THINNESTAI_API_KEY"

Best Practices

  1. Start with session memory only. Enable agentic memory once your agent's core behavior is solid.
  2. Review stored memories regularly. Make sure the agent is remembering useful things, not noise.
  3. Set appropriate history limits. Too much context can confuse the model and slow responses.
  4. Use persistent sessions for repeat callers. It dramatically improves the caller experience when the agent remembers them.
  5. Guide memory in your prompt. You can tell the agent what to remember:
    When a caller shares a preference (scheduling, communication, product),
    remember it for future calls. Don't remember small talk or one-time
    requests.

On this page