Skip to main content
Memory enables agents to maintain coherance over multiple-turns. Agents store a history of messages that include:
  • System messages.
  • User messages.
  • Model responses.
  • Tool calls and their results.
Memory works automatically. Behind the scenes, it uses a two-tier architecture with recent messages in fast in-memory storage and optional database persistence for durability.
from autonomy import Agent, Model, Node

async def main(node):
  agent = await Agent.start(
    node=node,
    name="henry",
    instructions="You are Henry, a legal research assistant",
    model=Model("claude-sonnet-4-v1")
  )

Node.start(main)
# First message - agent stores case details
curl --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "message":"I am working on Smith v. Johnson, a contract dispute",
    "conversation": "case-123"
  }' \
  "https://19f13800-myapp.cluster.autonomy.computer/agents/henry"

# Second message - agent recalls the case details
curl --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "message":"What case am I working on?",
    "conversation": "case-123"
  }' \
  "https://19f13800-myapp.cluster.autonomy.computer/agents/henry"

# Agent responds: "You are working on Smith v. Johnson, a contract dispute"
The agent automatically:
  1. Stores each user message in memory.
  2. Stores its own responses in memory.
  3. Stores tool calls and results in memory.
  4. Retrieves relevant history when building context.

Isolation

Isolated Conversations

Each conversation has its own isolated memory. Use different conversation identifiers to maintain separate conversation histories:
# Research on contract case
await agent.send("Research breach of contract defenses", conversation="contract-case")

# Research on tort case (completely separate memory)
await agent.send("Research negligence elements", conversation="tort-case")

# These conversations don't see each other's history
await agent.send("What was I researching?", conversation="contract-case")
# Agent only recalls the contract case research
curl --request POST \
  --header "Content-Type: application/json" \
  --data '{"message":"What have we discussed?", "conversation": "tort-case"}' \
  "https://19f13800-myapp.cluster.autonomy.computer/agents/henry"

Isolated Users (Scope)

For multi-tenant applications, add a scope parameter to isolate memory across users:
# Attorney Smith's case research
await agent.send(
  "I'm working on Smith v. Johnson, a contract dispute",
  scope="attorney-smith",
  conversation="case-research"
)

# Attorney Jones's case research (same conversation ID, different scope)
await agent.send(
  "I'm working on Davis v. Brown, a negligence case",
  scope="attorney-jones",
  conversation="case-research"
)

# Each attorney's memory is completely isolated
await agent.send(
  "What case am I working on?",
  scope="attorney-smith",
  conversation="case-research"
)
# Agent responds: "You're working on Smith v. Johnson, a contract dispute"
curl --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "message":"What case details did I provide?",
    "scope": "attorney-smith",
    "conversation": "case-research"
  }' \
  "https://19f13800-myapp.cluster.autonomy.computer/agents/henry"

Isolated Agents

Different agents have separate memory, even when serving the same user:
# Two different legal assistants
researcher = await Agent.start(node=node, name="henry", ...)
drafter = await Agent.start(node=node, name="sarah", ...)

# Same attorney and conversation ID, but separate memory
await researcher.send("Research contracts", scope="attorney-123", conversation="work")
await drafter.send("Draft a motion", scope="attorney-123", conversation="work")

# Each agent only sees its own conversation history

Memory Limits

By default, agents keep the last 100 messages or ~8,000 tokens in active memory (whichever limit is reached first). Older messages are automatically removed to stay within these limits. Messages are removed using FIFO (first in, first out) order - the oldest messages are removed first.

Memory and Context

Memory stores all conversation messages, but agents don’t always send all messages to the model. The Context template determines which messages to included in calls to the model.