Skip to main content

Persistent cognitive infrastructure for AI agents โ€” memory, procedural learning, and cross-agent intelligence that compounds over time.

Project description

๐Ÿง  Mnemonic SDKs

Persistent cognitive infrastructure for AI agents.

Agents that remember. Agents that improve. Agents that never make the same mistake twice.


The Problem

Every AI agent built today has the same fatal flaw: it forgets everything.

Run it a thousand times โ€” it still makes the same mistakes on run 1000 as it did on run 1. That's not intelligence. That's an expensive loop.

# Without Mnemonic โ€” agent starts from zero every time
response = agent.run("fix authentication bug")  # 5 retries, 4 mins, 1 failure
response = agent.run("fix authentication bug")  # 5 retries, 4 mins, 1 failure  
response = agent.run("fix authentication bug")  # 5 retries, 4 mins, 1 failure
# With Mnemonic โ€” agent learns from every execution
ctx = mnemonic.recall(agent_id="coder", task="fix authentication bug")
response = agent.run("fix authentication bug", context=ctx)
mnemonic.capture(agent_id="coder", task="fix auth bug", success=True)

# Run 1:  5 retries ยท 4 minutes  ยท 1 failure
# Run 5:  3 retries ยท 2 minutes  ยท 0 failures
# Run 10: 1 retry   ยท 45 seconds ยท 0 failures  โ† Mnemonic is working

70% reduction in token expenditure. Measurable. Reproducible. Compounding.


What Is Mnemonic?

Mnemonic is a cognitive infrastructure layer that sits between your AI agents and the world. Two SDK calls bracket every agent execution:

recall()  โ†’ before the agent runs  โ†’ inject accumulated intelligence
capture() โ†’ after the agent runs   โ†’ extract and store new lessons

Every execution gets reflected on by an LLM. Lessons are embedded into a vector knowledge graph. Relevant knowledge is recalled with semantic precision before the next run.

The agent doesn't just run. It evolves.


The Four Pillars of Agent Cognition

Pillar What it does
Procedural Learning Agents learn HOW to do tasks better from outcomes
Episodic Memory Every execution is logged, reflected on, and distilled
Cross-Agent Intelligence Agent A learns โ†’ Agent B starts smarter (network effect)
Workflow Evolution Procedures self-optimise based on success and failure patterns

Install

Python

pip install mnemonic-sdk

With integrations:

pip install mnemonic-sdk[openai]      # OpenAI SDK wrapper
pip install mnemonic-sdk[anthropic]   # Anthropic SDK wrapper  
pip install mnemonic-sdk[all]         # Everything

JavaScript / TypeScript

npm install @mnemonicai.official/sdk-js

Quick Start

Python

from mnemonic import Mnemonic

m = Mnemonic(api_key="mnemonic_sk_...")

# Step 1: Recall accumulated intelligence before the task
context = m.recall(
    agent_id="coder-agent",
    task="fix JWT authentication bug",
    as_prompt=True  # returns formatted string for LLM injection
)

# Step 2: Run your agent with the recalled context
response = your_agent.run(task, context=context)

# Step 3: Capture the outcome โ€” reflection happens automatically
m.capture(
    agent_id="coder-agent",
    task="fix JWT authentication bug",
    actions=[{"type": "edit", "target": "auth.py"}],
    output=response.output,
    success=True,
    retries=2,
    time_taken=45000  # ms
)

JavaScript / TypeScript

import { Mnemonic } from '@mnemonicai.official/sdk-js';

const mnemonic = new Mnemonic({ apiKey: 'mnemonic_sk_...' });

// Recall before task
const memory = await mnemonic.recall({
  agentId: 'coder-agent',
  task: 'fix JWT authentication bug',
  asPrompt: true
});

// Run agent with context
const result = await yourAgent.run(task, { context: memory.prompt });

// Capture after task
await mnemonic.capture({
  agentId: 'coder-agent',
  task: 'fix JWT authentication bug',
  actions: [{ type: 'edit', target: 'auth.py' }],
  output: result.output,
  success: true,
  retries: 2,
  timeTaken: 45000
});

OpenAI Integration

from mnemonic.integrations.openai import MnemonicOpenAI
from openai import OpenAI

client = MnemonicOpenAI(
    openai_client=OpenAI(),
    mnemonic_api_key="mnemonic_sk_...",
    agent_id="my-openai-agent"
)

# Mnemonic wraps every chat completion automatically
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Fix the authentication bug"}]
)
# recall() and capture() happen automatically โ€” zero code changes

Claude / Anthropic Integration

from mnemonic.integrations.claude import MnemonicClaude
from anthropic import Anthropic

client = MnemonicClaude(
    anthropic_client=Anthropic(),
    mnemonic_api_key="mnemonic_sk_...",
    agent_id="my-claude-agent"
)

response = client.messages.create(
    model="claude-opus-4-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Deploy to production"}]
)
# Fully wrapped โ€” memory handled transparently

The Network Effect

The real breakthrough isn't what one agent learns. It's what happens when thousands of agents learn simultaneously and share that intelligence.

Agent A encounters a production failure
  โ†’ Mnemonic reflects, extracts the operational lesson
  โ†’ Lesson propagates across the cognitive layer

Agent B โ€” running the same task class at a different company
  โ†’ Starts with Agent A's accumulated intelligence
  โ†’ Never makes that mistake

That's collective intelligence. That's the network effect nobody in this space has architected for.


Benchmark Results

Run against a real coding agent on a repeating task class (authentication bug fixes):

Run Retries Time Failures Token Cost
1 5 4min 1 100%
3 3 2min 0 68%
5 2 90s 0 45%
10 1 45s 0 30%

70% token reduction. 94% time reduction. Zero repeated failures.


API Reference

recall(agent_id, task, limit=10, as_prompt=False)

Semantic vector search across accumulated lessons and procedures. Returns the most relevant operational intelligence for the given task.

Returns: RecallResponse with lessons, procedures, and optionally prompt (formatted for LLM injection).

capture(agent_id, task, actions, output, success, retries=0, time_taken=None)

Logs an agent execution. Triggers async reflection via LLM โ€” extracts lessons, embeds them, stores in vector graph. Returns immediately (reflection is non-blocking).

get_agent_stats(agent_id)

Returns improvement metrics: retry reduction, token savings, success rate trends across all executions.

feedback(lesson_id, rating)

Rate a lesson: useful ยท outdated ยท wrong ยท great. Adjusts confidence scores in real time.


Architecture

Your Agent
    โ”‚
    โ”œโ”€โ”€ recall()  โ†โ”€โ”€โ”€ pgvector HNSW semantic search
    โ”‚                  โ†‘
    โ”‚              Lesson Store
    โ”‚                  โ†‘
    โ””โ”€โ”€ capture() โ”€โ”€โ”€โ†’ ARQ Worker โ†’ Claude Sonnet 4.5
                                    (reflection engine)
                                    โ†“
                                Extract lessons
                                Embed (1536-dim)
                                Store + reinforce

Stack: FastAPI ยท PostgreSQL 16 ยท pgvector ยท Redis ยท ARQ ยท Claude Sonnet 4.5 ยท OpenAI text-embedding-3-small


Self-Hosting

git clone https://github.com/Nirvana3339/mnemonic
cd mnemonic

cp .env.example .env
# Fill in: DATABASE_URL, REDIS_URL, OPENAI_API_KEY, ANTHROPIC_API_KEY, SECRET_KEY

docker-compose up

API available at http://localhost:8001/api/health


Pricing

Plan Price Agents Reflections
OSS / Self-Host Free forever Unlimited Unlimited
Starter $29/month 5 1,000/month
Pro $79/month 25 5,000/month
Team $199/month Unlimited 10,000/month
Enterprise Custom Unlimited Unlimited

Repository Structure

mnemonic-sdks/
โ”œโ”€โ”€ python/                     โ† pip install mnemonic-sdk
โ”‚   โ”œโ”€โ”€ mnemonic/
โ”‚   โ”‚   โ”œโ”€โ”€ client.py           # Synchronous client
โ”‚   โ”‚   โ”œโ”€โ”€ async_client.py     # Async client
โ”‚   โ”‚   โ”œโ”€โ”€ models.py           # Pydantic models
โ”‚   โ”‚   โ”œโ”€โ”€ exceptions.py       # Error types
โ”‚   โ”‚   โ””โ”€โ”€ integrations/
โ”‚   โ”‚       โ”œโ”€โ”€ openai.py       # OpenAI SDK wrapper
โ”‚   โ”‚       โ””โ”€โ”€ claude.py       # Anthropic SDK wrapper
โ”‚   โ”œโ”€โ”€ examples/
โ”‚   โ””โ”€โ”€ pyproject.toml
โ”‚
โ”œโ”€โ”€ javascript/                 โ† npm install @mnemonicai.official/sdk-js
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ client.ts           # Main client
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts            # TypeScript interfaces
โ”‚   โ”‚   โ”œโ”€โ”€ errors.ts           # Error classes
โ”‚   โ”‚   โ””โ”€โ”€ index.ts            # Exports
โ”‚   โ”œโ”€โ”€ examples/
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ””โ”€โ”€ examples/                   โ† Cross-language examples

Roadmap

  • v1 (Now): Procedural learning ยท Python + JS SDKs ยท REST API ยท Self-hostable
  • v2: Cross-agent knowledge graph ยท LangChain + AutoGen integrations ยท JS async client
  • v3: Org cognition ยท Slack/Notion/Jira connectors ยท SOC 2
  • v4: Workflow evolution ยท Causal reasoning ยท Domain expansion (sales, legal, finance)

Contributing

We welcome contributions. See CONTRIBUTING.md for guidelines.

git clone https://github.com/Nirvana3339/mnemonic-sdks
cd mnemonic-sdks/python
pip install -e ".[all]"

License

MIT โ€” see LICENSE


Built by Nishant Vanawala in Melbourne, Australia

The cognitive operating layer for the age of autonomous agents.

mnemonic.dev ยท hello@mnemonic.dev ยท npm

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mnemonic_sdk-0.1.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mnemonic_sdk-0.1.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file mnemonic_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: mnemonic_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for mnemonic_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1270347391e7f23aea6e651717a0b319b769f54ea60169e75b81152d15069c2e
MD5 eb68ebbf756cca7c8b02727d62483850
BLAKE2b-256 c29aa0259bdc2284fd59d3708fde79277e6baab506fcd6bd3d0b0675c8f0f594

See more details on using hashes here.

File details

Details for the file mnemonic_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mnemonic_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for mnemonic_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b24361cb06f2124e76cb6d9ea5f4ed34b391132e9d7bfd7325993935da12bdf
MD5 3a45d964a6226a1d2a807b9b80b5196d
BLAKE2b-256 2854eabe04da9cbff04af5e8a2afe576b51bc3d3c4470b0f5ed9a55b3dfcff4f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page