Appearance
Letta Code SDK Overview
FreshSource: Letta Code SDK
What is the Letta Code SDK?
The Letta Code SDK provides a programmatic interface to Letta Code, enabling you to build applications that leverage Letta Code's advanced coding agent harness with persistent memory.
Installation
bash
npm install @letta-ai/letta-code-sdkQuick Start
One-Shot Query
Simple queries that return an immediate response without persistence:
typescript
import { prompt } from '@letta-ai/letta-code-sdk';
const result = await prompt('What does the main function do?');
console.log(result);Persistent Agent
Multi-turn conversations with memory across sessions:
typescript
import { createAgent, resumeSession } from '@letta-ai/letta-code-sdk';
// Create a new agent with memory
const session = await createAgent({
memoryBlocks: [
{ label: 'persona', value: 'You are a senior TypeScript engineer.' },
{ label: 'human', value: 'Prefers functional patterns and strict types.' }
]
});
// Send messages
const response = await session.send('Review the auth module for security issues');
console.log(response);
// Close the session
await session.close();
// Later: resume with full memory context
const resumed = await resumeSession(session.agentId);
const followUp = await resumed.send('Did you find any issues last time?');Streaming Responses
typescript
const session = await createAgent();
for await (const chunk of session.stream('Explain the architecture')) {
process.stdout.write(chunk);
}
await session.close();Key Concepts
| Concept | Description |
|---|---|
| Agent | Persistent entity with memory that survives across sessions |
| Conversation | A message thread within an agent; multiple can coexist |
| Session | A single execution/connection to an agent |
| Default Conversation | Auto-created with each agent; accessed via resumeSession(agentId) |
Session Auto-Close
With TypeScript 5.2+, sessions auto-close using the await using syntax:
typescript
await using session = await createAgent();
await session.send('Hello!');
// Session automatically closes when scope exitsFor older TypeScript versions, always call session.close() manually.
Next Steps
- API Reference - Complete function signatures and types
- Migration Guide - Migrating from Claude Agent SDK
- Agents - Deep dive into agent configuration