-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
The GET /v1/agents/{agent_id}/core-memory/blocks endpoint returns duplicate blocks when paginating.
The same block IDs are returned multiple times across pagination requests, resulting in the client receiving more blocks than actually exist.
Example
An agent created with 3 memory blocks (persona, system, human) returns:
- Total blocks returned: 6
- Unique block IDs: 3
Block ID counts
block-ce930f61-e152-4e98-9a18-315b35581803— 3 times (system)block-22ecddf7-93f5-4f6a-9807-85bf7372a80d— 2 times (human)block-6fec3b2e-002a-443f-8ef0-1469cb143d82— 1 time (persona)
Server logs
The server shows multiple paginated requests being made:
GET /v1/agents/{id}/core-memory/blocks HTTP/1.1 200 OK
GET /v1/agents/{id}/core-memory/blocks?after=block-3553bfbb-... HTTP/1.1 200 OK
GET /v1/agents/{id}/core-memory/blocks?after=block-65e0062e-... HTTP/1.1 200 OK
GET /v1/agents/{id}/core-memory/blocks?after=block-6fec3b2e-... HTTP/1.1 200 OK
The pagination logic appears to not properly exclude already-returned blocks.
Note: Block updates still work correctly (all duplicates point to the same underlying block), so this is primarily a listing/display issue.
Please describe your setup
How are you running Letta?
- Docker
Environment
- OS: macOS (Darwin 24.5.0)
- Deployment: Docker Compose using
letta/letta:latest - Client:
letta-client(latest)
Reproduction steps
from letta_client import Letta
client = Letta(base_url="http://localhost:8283")
# Create an agent with memory blocks
agent = client.agents.create(
name="test-agent",
model="openai/gpt-4o-mini",
embedding="openai/text-embedding-ada-002",
memory_blocks=[
{"label": "persona", "value": "You are a helpful assistant."},
{"label": "system", "value": "System instructions here."},
{"label": "human", "value": "User context here."},
],
)
# List blocks - returns duplicates
blocks = list(client.agents.blocks.list(agent_id=agent.id))
print(f"Total blocks returned: {len(blocks)}") # Returns 6, expected 3
# Verify duplicates
block_ids = [b.id for b in blocks]
unique_ids = set(block_ids)
print(f"Unique block IDs: {len(unique_ids)}") # Returns 3
from collections import Counter
for bid, count in Counter(block_ids).items():
if count > 1:
print(f"Duplicate: {bid} appears {count} times")Expected behavior
client.agents.blocks.list() should return each block exactly once.
For this example, the expected result is 3 total blocks.
Additional context
Model: openai/gpt-4o-mini
Embedding: openai/text-embedding-ada-002
Issue persists with freshly created agents
Deleting and recreating the agent does not resolve the issue