| name | using-letta-api |
| description | Code-heavy guide for managing yourself and subagents via the Letta Python client. Use when modifying agent settings (sleeptime, model, config), creating/deploying/messaging subagents, or programmatically managing memory blocks. |
Using Letta API for Self-Management
This skill provides runnable Python snippets for self-modification via the Letta API.
Setup
from letta_client import Letta
client = Letta(base_url='https://api.letta.com')
import os
AGENT_ID = os.environ.get('LETTA_AGENT_ID', 'agent-xxx')
Quick Reference
Common Patterns
Disable Sleeptime
client.agents.update(AGENT_ID, enable_sleeptime=False)
Message a Subagent
response = client.agents.messages.create(
agent_id='agent-xxx-subagent-id',
messages=[{'role': 'user', 'content': 'Your task here'}]
)
print(response.messages[-1].content)
Update a Memory Block
client.agents.blocks.update(
'block-label',
agent_id=AGENT_ID,
value='New content here'
)
When to Use API vs Other Methods
| Method | Use When |
|---|
| Letta API | Modifying subagents, agent config, programmatic block updates |
| memfs (file edits) | Updating your own memory blocks (auto-syncs) |
| Task tool | Deploying subagents for work (preferred for most tasks) |
Load the reference files as needed for detailed patterns.