New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@letta-ai/agentic-learning

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@letta-ai/agentic-learning

Drop-in SDK to add an AI memory layer to any application. Works with OpenAI, Anthropic, Gemini, Claude, Vercel AI SDK.

latest
Source
npmnpm
Version
0.4.3
Version published
Maintainers
4
Created
Source

Learning SDK - AI Memory Layer for Any Application

Add continual learning and long-term memory to any LLM agent with one line of code. This SDK enables agents to learn from every conversation and recall context across sessions—making any agent across any platform stateful.

import OpenAI from 'openai';
import { learning } from '@letta-ai/agentic-learning';

const client = new OpenAI();

await learning({ agent: 'my_agent' }, async () => {
    // LLM is now stateful!
    response = await client.chat.completions.create(...) 
});

npm shield License Tests

Installation

npm install @letta-ai/agentic-learning

Quick Start

# Set your API keys
export OPENAI_API_KEY="your-openai-key"
export LETTA_API_KEY="your-letta-key"
import { learning } from '@letta-ai/agentic-learning';
import OpenAI from 'openai';

const client = new OpenAI();

// Add continual learning with one line
await learning({ agent: "my_assistant" }, async () => {
    // All LLM calls inside this block have learning enabled
    const response = await client.chat.completions.create({
        model: "gpt-5",
        messages: [{ role: "user", content: "My name is Alice" }]
    });

    // Agent remembers prior context
    const response2 = await client.chat.completions.create({
        model: "gpt-5",
        messages: [{ role: "user", content: "What's my name?" }]
    });
    // Returns: "Your name is Alice"
});

That's it - this SDK automatically:

  • ✅ Learns from every conversation
  • ✅ Recalls relevant context when needed
  • ✅ Remembers across sessions
  • ✅ Works with your existing LLM code

Supported Providers

ProviderPackageStatusExample
OpenAI Chatopenai>=4.0.0✅ Stableopenai_example.ts
OpenAI Responsesopenai>=4.0.0✅ Stableopenai_responses_example.ts
Anthropic@anthropic-ai/sdk>=0.30.0✅ Stableanthropic_example.ts
Claude Agent SDK@anthropic-ai/claude-agent-sdk>=0.1.0✅ Stableclaude_example.ts
Gemini@google/generative-ai>=0.21.0✅ Stablegemini_example.ts
Vercel AI SDKai>=3.0.0✅ Stablevercel_example.ts

Create an issue to request support for another provider, or contribute a PR.

How It Works

This SDK adds stateful memory to your existing LLM code with zero architectural changes:

Benefits:

  • 🔌 Drop-in integration - Works with your existing LLM Provider SDK code
  • 🧠 Automatic memory - Relevant context retrieved and injected into prompts
  • 💾 Persistent across sessions - Conversations remembered even after restarts
  • 💰 Cost-effective - Only relevant context injected, reducing token usage
  • Fast retrieval - Semantic search powered by Letta's optimized infrastructure
  • 🏢 Production-ready - Built on Letta's proven memory management platform

Architecture:

1. 🎯 Wrap      2. 📝 Capture       3. 🔍 Retrieve   4. 🤖 Respond
   your code       conversations      relevant         with full
   in learning     automatically      memories         context

┌─────────────┐
│  Your Code  │
│  learning() │
└──────┬──────┘
       │
       ▼
┌─────────────┐    ┌──────────────┐
│ Interceptor │───▶│ Letta Server │  (Stores conversations,
│  (Inject)   │◀───│  (Memory)    │   retrieves context)
└──────┬──────┘    └──────────────┘
       │
       ▼
┌─────────────┐
│  LLM API    │  (Sees enriched prompts)
│ OpenAI/etc  │
└─────────────┘

Key Features

Memory Across Sessions

// First session
await learning({ agent: "sales_bot" }, async () => {
    const response = await client.chat.completions.create({
        messages: [{ role: "user", content: "I'm interested in Product X" }]
    });
});

// Later session - agent remembers automatically
await learning({ agent: "sales_bot" }, async () => {
    const response = await client.chat.completions.create({
        messages: [{ role: "user", content: "Tell me more about that product" }]
    });
    // Agent knows you're asking about Product X
});

Search Agent Memory

import { AgenticLearning } from '@letta-ai/agentic-learning';

const learningClient = new AgenticLearning();

// Search past conversations
const messages = await learningClient.memory.search({
    agent: "my_agent",
    query: "What are my project requirements?"
});

Advanced Features

Capture-Only Mode

// Store conversations without injecting memory (useful for logging)
await learning({ agent: "my_agent", captureOnly: true }, async () => {
    const response = await client.chat.completions.create(...);
});

Custom Memory Blocks

// Configure which memory blocks to use
await learning({ agent: "sales_bot", memory: ["customer", "product_preferences"] }, async () => {
    const response = await client.chat.completions.create(...);
});

Local Development

Using Local Letta Server

import { AgenticLearning, learning } from '@letta-ai/agentic-learning';

// Connect to local server
const learningClient = new AgenticLearning({
    baseUrl: "http://localhost:8283"
});

await learning({ agent: 'my_agent', client: learningClient }, async () => {
    const response = await client.chat.completions.create(...);
});

Run Letta locally with Docker:

docker run \
  -v ~/.letta/.persist/pgdata:/var/lib/postgresql/data \
  -p 8283:8283 \
  -e OPENAI_API_KEY="your_key" \
  letta/letta:latest

See the self-hosting guide for more options.

Development Setup

# Clone repository
git clone https://github.com/letta-ai/agentic-learning-sdk.git
cd agentic-learning-sdk/typescript

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run Claude tests (separate runner)
npm run test:claude

# Watch mode
npm run dev

Examples

See the examples/ directory for complete working examples:

cd ../examples
npm install
npx tsx openai_example.ts

Documentation

Requirements

  • Node.js 18+
  • Letta API key (sign up at letta.com)
  • At least one LLM provider SDK

License

Apache 2.0 - See LICENSE for details.

Built with Letta - the leading platform for building stateful AI agents with long-term memory.

Keywords

ai-memory

FAQs

Package last updated on 02 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts