Skip to content

Instantly share code, notes, and snippets.

@cpfiffer
Created December 1, 2025 19:15
Show Gist options
  • Select an option

  • Save cpfiffer/121693bbb21f522ac4e06a7b7221af26 to your computer and use it in GitHub Desktop.

Select an option

Save cpfiffer/121693bbb21f522ac4e06a7b7221af26 to your computer and use it in GitHub Desktop.
how to share archives between letta agents
from letta_client import Letta
import os
# Initialize client
client = Letta(api_key=os.getenv("LETTA_API_KEY"))
config = client.models.embeddings.list()[0]
agent = client.agents.create(
name="agent",
model="openai/gpt-5-mini",
tools=["archival_memory_search", "archival_memory_insert"],
)
print(f"Created agent {agent.id}")
agent2 = client.agents.create(
name="agent2",
model="openai/gpt-5-mini",
tools=["archival_memory_search", "archival_memory_insert"],
)
print(f"Created agent {agent2.id}")
# Create an archive
archive = client.archives.create(
name="test",
description="An archive for testing shared archives.",
embedding_config=config
)
print(archive)
# Attach the archive to the agent
client.agents.archives.attach(archive.id, agent_id=agent.id)
client.agents.archives.attach(archive.id, agent_id=agent2.id)
# Print out the attached archives
archive = client.archives.list(agent_id=agent.id)
print(archive)
# Ask the first agent to insert a memory.
response = client.agents.messages.create(
agent.id,
input="Please insert an archival memory reading 'red' using your tool."
)
print(response)
# Ask the second agent to read from memory.
response2 = client.agents.messages.create(
agent2.id,
input="Please search your archival memory using the query 'colors'. Summarize what you find."
)
print(response2)
client.agents.delete(agent.id)
print(f"Deleted agent {agent.id}")
client.agents.delete(agent2.id)
print(f"Deleted agent {agent2.id}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment