Letta Code SDK migration guide
Migrate from the Claude Agent SDK to the Letta Code SDK
The Claude Agent SDK is query-based and does not expose a persistent agent entity; state lives in a session/thread resumed by session_id.
Letta Code SDK is agent-based with persistent memory, and also supports multiple conversation threads per agent. The closest mental model depends on which Claude SDK interface you’re using.
Claude Agent SDK V2 (preview)
Section titled “Claude Agent SDK V2 (preview)”V2 uses createSession / resumeSession with an explicit send() / stream() cycle per turn. This maps closely to Letta Code SDK.
High-level mapping (V2)
Section titled “High-level mapping (V2)”| Claude Agent SDK V2 | Letta Code SDK |
|---|---|
unstable_v2_prompt(...) | prompt(...) |
unstable_v2_createSession(...) | createSession(...) |
unstable_v2_resumeSession(session_id) | resumeSession(conversationId) |
session.send(...) | session.send(...) |
session.stream() | session.stream() |
- Claude
session_idcorresponds to LettaconversationId. - Letta sessions are anchored to a persistent agent; Claude sessions are ephemeral unless you store the session ID.
- If you want stateless behavior, use
prompt(...)or create a fresh agent per run.
Claude Agent SDK V1 (query-based)
Section titled “Claude Agent SDK V1 (query-based)”V1 streams results from a single query(...) async generator. In Letta Code SDK, use prompt(...) for one-shots or createSession(...).send() + stream() for multi-turn flows.
High-level mapping (V1)
Section titled “High-level mapping (V1)”| Claude Agent SDK V1 | Letta Code SDK |
|---|---|
query({ prompt, options }) | prompt(message) or createSession(...).send() |
Key differences
Section titled “Key differences”| Feature | Claude Agent SDK | Letta Code SDK |
|---|---|---|
| Persistence model | Session-based (ephemeral) | Agent-based (persistent) |
| Memory | Session state only | Persistent memory blocks |
| Model support | Claude only | Claude, GPT, Gemini, local models |
| Multiple conversations | One per session | Multiple per agent |
Permissions and interactive tools
Section titled “Permissions and interactive tools”If you used Claude’s permission/user-input handling, the closest Letta Code SDK controls are:
canUseTool(toolName, toolInput)for runtime approval decisions.allowedTools/disallowedToolsfor coarse allow/deny policy.permissionMode(default,acceptEdits,plan,bypassPermissions) for global behavior.
In non-interactive headless flows, tools that require runtime user input (for example AskUserQuestion and ExitPlanMode) should be handled in canUseTool or blocked with disallowedTools.
Example migration
Section titled “Example migration”Before (Claude Agent SDK V2)
Section titled “Before (Claude Agent SDK V2)”import { unstable_v2_createSession, unstable_v2_resumeSession,} from "@anthropic-ai/claude-agent-sdk";
// Create new sessionawait using session = unstable_v2_createSession({ systemPrompt: "You are a helpful assistant.",});
// Send messageawait session.send("Hello!");for await (const msg of session.stream()) { console.log(msg);}
// Resume laterawait using resumed = unstable_v2_resumeSession(session.sessionId);After (Letta Code SDK)
Section titled “After (Letta Code SDK)”import { createAgent, resumeSession } from "@letta-ai/letta-code-sdk";
// Create new agent (persistent)const agentId = await createAgent({ systemPrompt: "You are a helpful assistant.",});
// Resume agent's default conversationawait using session = resumeSession(agentId);
// Send messageawait session.send("Hello!");for await (const msg of session.stream()) { console.log(msg);}
// Resume later - just use the agentIdawait using resumed = resumeSession(agentId);Note: In the Claude Agent SDK, you must save
sessionIdto resume. In Letta Code SDK, the agent persists—just useresumeSession(agentId)to continue where you left off.For multiple concurrent conversations, use
createSession(agentId)andresumeSession(conversationId).