Appearance
Migration Guide - Claude Agent SDK to Letta Code SDK
FreshSource: Letta Code SDK Migration
Key Differences
The Claude Agent SDK is query-based with ephemeral sessions. The Letta Code SDK uses persistent agents with multiple conversation threads.
Feature Comparison
| Feature | Claude Agent SDK | Letta Code SDK |
|---|---|---|
| Persistence | Session-based | Agent-based |
| Memory | Session state only | Persistent memory blocks |
| Models | Claude only | Multiple options |
| Conversations | One per session | Multiple per agent |
Claude Agent SDK V2 Migration
Function Mapping
| Claude V2 | Letta Code SDK |
|---|---|
unstable_v2_prompt() | prompt() |
unstable_v2_createSession() | createSession() |
unstable_v2_resumeSession(session_id) | resumeSession(conversationId) |
Before (Claude V2)
typescript
import { unstable_v2_createSession, unstable_v2_resumeSession } from '@anthropic-ai/claude-code-sdk';
// Create session
const session = await unstable_v2_createSession();
const sessionId = session.sessionId;
// Resume later
const resumed = await unstable_v2_resumeSession(sessionId);After (Letta Code SDK)
typescript
import { createAgent, resumeSession } from '@letta-ai/letta-code-sdk';
// Create agent (persistent)
const session = await createAgent();
const agentId = session.agentId;
// Resume later - the agent persists, just reconnect
const resumed = await resumeSession(agentId);Key Insight
With Letta, the agent persists -- just use resumeSession(agentId) to continue where you left off. No need to manage session IDs separately.
Claude Agent SDK V1 Migration
Function Mapping
| Claude V1 | Letta Code SDK |
|---|---|
query() (one-shot) | prompt(message) |
query() (multi-turn) | createSession().send() + stream() |
Before (Claude V1)
typescript
import { query } from '@anthropic-ai/claude-code-sdk';
const result = await query('What does this function do?');After (Letta Code SDK)
typescript
import { prompt, createSession } from '@letta-ai/letta-code-sdk';
// One-shot (same as V1 query)
const result = await prompt('What does this function do?');
// Multi-turn (new capability)
const session = await createSession();
const response = await session.send('Explain the auth module');
const followUp = await session.send('What about the middleware?');
await session.close();Permissions and Tools
Claude SDK
Limited permission control, typically all-or-nothing.
Letta Code SDK
Fine-grained control:
typescript
const session = await createAgent({
// ... agent config
});
// Resume with restricted tools
const restricted = await resumeSession(session.agentId, {
allowedTools: ['Read', 'Glob', 'Grep'],
permissionMode: 'plan',
canUseTool: (tool) => {
// Custom approval logic
return tool !== 'Write';
}
});Migration Checklist
- [ ] Replace Claude SDK import with
@letta-ai/letta-code-sdk - [ ] Map V1
query()calls toprompt() - [ ] Map V2
unstable_v2_*calls to their Letta equivalents - [ ] Replace session ID tracking with agent ID tracking
- [ ] Add memory block configuration where beneficial
- [ ] Update permission/tool configurations
- [ ] Test that agent memory persists across sessions
See Also
- SDK Overview - Full SDK capabilities
- API Reference - Function signatures
- Agents - Agent lifecycle