Agent Learning Memory Architecture - Persistent memory for AI agents
Project description
ALMA - Agent Learning Memory Architecture
A reusable harness pattern for creating AI agents that learn and improve over time through structured memory - without model weight updates.
The Harness Pattern
ALMA isn't just agent memory - it's a generalized framework for any tool-using workflow:
┌─────────────────────────────────────────────────────────────────┐
│ 1. SETTING Fixed environment: tools, constraints │
├─────────────────────────────────────────────────────────────────┤
│ 2. CONTEXT Ephemeral per-run inputs: task, user │
├─────────────────────────────────────────────────────────────────┤
│ 3. AGENT The executor with scoped intelligence │
├─────────────────────────────────────────────────────────────────┤
│ 4. MEMORY SCHEMA Domain-specific learning structure │
└─────────────────────────────────────────────────────────────────┘
The Flow:
- Pre-run: Inject relevant memory slices ("Past successes in similar tasks")
- Run: Agent acts using tools, logs reflections
- Post-run: Update memory schema
- Repeat: Agent appears to "learn" without weight changes
Why This Matters
Code exists ≠ Knowledge retained
Knowledge retained ≠ Knowledge scoped
Knowledge scoped ≠ Knowledge retrieved efficiently
ALMA solves all three through scoped memory injection. Agents get smarter via better-informed prompts, not model changes.
Supported Domains
ALMA works for ANY tool-using workflow:
| Domain | Agents | Use Case |
|---|---|---|
| Coding | Helena, Victor | Testing, API development |
| Research | Researcher | Market analysis, competitive intelligence |
| Content | Copywriter, Documenter | Marketing, documentation |
| Operations | Support | Customer service, automation |
Quick Start
Installation
pip install alma-memory
# or from source
pip install git+https://github.com/RBKunnela/ALMA-memory.git
Using the Harness Pattern
from alma import ALMA, create_harness, Context
# Initialize ALMA
alma = ALMA.from_config(".alma/config.yaml")
# Create a domain-specific harness
harness = create_harness("coding", "helena", alma)
# Define task context
context = Context(
task="Test the login form validation",
project_id="my-app",
user_id="developer-1",
inputs={"component": "LoginForm", "priority": "high"}
)
# Run with memory injection
result = harness.run(context)
# The harness automatically:
# 1. Retrieved relevant memories (testing strategies, past outcomes)
# 2. Built the prompt with injected knowledge
# 3. Will log the outcome for future learning
Creating Custom Agents
from alma import (
ALMA, Harness, Setting, Agent, MemorySchema, Tool, ToolType
)
# Define the environment
setting = Setting(
name="Bio Research Environment",
description="Tools for biological data analysis",
tools=[
Tool(
name="sequence_search",
description="Search genomic databases",
tool_type=ToolType.SEARCH,
),
Tool(
name="structure_analysis",
description="Analyze protein structures",
tool_type=ToolType.ANALYSIS,
),
],
global_constraints=[
"Cite all data sources",
"Note confidence levels",
],
)
# Define what this agent can learn
schema = MemorySchema(
domain="bioinformatics",
description="Patterns for biological data analysis",
learnable_categories=[
"search_refinements",
"analysis_patterns",
"data_interpretation",
],
forbidden_categories=[
"medical_diagnosis", # Out of scope
],
min_occurrences=5,
)
# Create the agent
agent = Agent(
name="bio_researcher",
role="Bioinformatics Analyst",
description="Expert in genomic analysis and protein structure prediction",
memory_schema=schema,
)
# Assemble the harness
alma = ALMA.from_config(".alma/config.yaml")
harness = Harness(setting=setting, agent=agent, alma=alma)
Basic Memory Operations
from alma import ALMA
alma = ALMA.from_config(".alma/config.yaml")
# Retrieve relevant memories
memories = alma.retrieve(
task="Test the login form validation",
agent="helena",
top_k=5
)
# Inject into prompt
prompt = f"""
## Your Task
Test the login form validation
## Relevant Knowledge (from past runs)
{memories.to_prompt()}
"""
# After task completion, learn from the outcome
alma.learn(
agent="helena",
task="Test login form",
outcome="success",
strategy_used="Tested empty fields, invalid email, valid submission",
feedback="User confirmed tests were thorough"
)
Memory Types
| Type | What It Stores | Example |
|---|---|---|
| Heuristic | Learned strategies | "For forms with >5 fields, test validation incrementally" |
| Outcome | Task results | "Login test succeeded using JWT token strategy" |
| Preference | User constraints | "User prefers verbose test output" |
| Domain Knowledge | Accumulated facts | "Login uses OAuth 2.0 with 24h token expiry" |
| Anti-pattern | What NOT to do | "Don't use sleep() for async waits - causes flaky tests" |
Configuration
Create .alma/config.yaml:
alma:
project_id: "my-project"
storage: sqlite # or "azure" for production
domains:
coding:
enabled: true
agents: [helena, victor]
research:
enabled: true
agents: [researcher]
agents:
helena:
domain: coding
can_learn:
- testing_strategies
- selector_patterns
cannot_learn:
- backend_logic
min_occurrences_for_heuristic: 3
researcher:
domain: research
can_learn:
- trend_patterns
- source_reliability
cannot_learn:
- code_implementation
min_occurrences_for_heuristic: 5
Storage Backends
| Backend | Use Case | Vector Search |
|---|---|---|
azure |
Production | Cosmos DB with vector search |
sqlite |
Local dev | SQLite + FAISS |
file |
Testing | JSON files (no vector search) |
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ HARNESS PATTERN │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ Setting │ │ Context │ │ Agent │ │MemorySchema │ │
│ │ (tools) │ │ (task) │ │(executor)│ │ (learning) │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────┐
│ ALMA CORE │
│ ┌────────────┐ ┌────────────┐ ┌────────────────────────┐ │
│ │ Retrieval │ │ Learning │ │ Storage │ │
│ │ Engine │ │ Protocol │ │ (Azure/SQLite/File) │ │
│ └────────────┘ └────────────┘ └────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────┐
│ MEMORY TYPES │
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌──────────┐ │
│ │ Heuristics │ │ Outcomes │ │Preferences │ │Anti-patt.│ │
│ └────────────┘ └────────────┘ └────────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────────────┘
Documentation
- PRD - Full product requirements
- Harness Pattern - Deep dive on the pattern
- API Reference - Coming soon
Status
| Phase | Description | Status |
|---|---|---|
| 1 | Core Abstractions | Done |
| 2 | Local Storage (SQLite + FAISS) | Done |
| 3 | Retrieval Engine | In Progress |
| 4 | Learning Protocols | Todo |
| 5 | Agent Integration (Helena + Victor) | Todo |
| 6 | Azure Cosmos DB | Todo |
| 7 | Cache Layer | Todo |
| 8 | Forgetting Mechanism | Todo |
License
MIT
Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alma_memory-0.2.0.tar.gz.
File metadata
- Download URL: alma_memory-0.2.0.tar.gz
- Upload date:
- Size: 80.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d355b1a05bca4108a6ec4ec97c34dc977da2e212fdc3b22e03a66396ac31255
|
|
| MD5 |
2994932ebd6d7cdfd538e3ac1ace973b
|
|
| BLAKE2b-256 |
6cc56958b86125c04ca003796dfb7b0de1e859f1134040562c2fd78a64acd117
|
Provenance
The following attestation bundles were made for alma_memory-0.2.0.tar.gz:
Publisher:
publish.yml on RBKunnela/ALMA-memory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alma_memory-0.2.0.tar.gz -
Subject digest:
8d355b1a05bca4108a6ec4ec97c34dc977da2e212fdc3b22e03a66396ac31255 - Sigstore transparency entry: 849825494
- Sigstore integration time:
-
Permalink:
RBKunnela/ALMA-memory@bdf7f236c1d4df02d2388d6a2f2d234bb583ac84 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/RBKunnela
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bdf7f236c1d4df02d2388d6a2f2d234bb583ac84 -
Trigger Event:
release
-
Statement type:
File details
Details for the file alma_memory-0.2.0-py3-none-any.whl.
File metadata
- Download URL: alma_memory-0.2.0-py3-none-any.whl
- Upload date:
- Size: 93.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24e50ace26ded9945f2bdd4d1f501c6992f473de9196a7e8946bb2c185cce210
|
|
| MD5 |
c11fc1d1a38783b0a0595a4b6c9eb6da
|
|
| BLAKE2b-256 |
8c296a7c42b6f64ba953c1b9948d58ba0dceb07439f3df822457e40698a1a288
|
Provenance
The following attestation bundles were made for alma_memory-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on RBKunnela/ALMA-memory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alma_memory-0.2.0-py3-none-any.whl -
Subject digest:
24e50ace26ded9945f2bdd4d1f501c6992f473de9196a7e8946bb2c185cce210 - Sigstore transparency entry: 849825497
- Sigstore integration time:
-
Permalink:
RBKunnela/ALMA-memory@bdf7f236c1d4df02d2388d6a2f2d234bb583ac84 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/RBKunnela
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bdf7f236c1d4df02d2388d6a2f2d234bb583ac84 -
Trigger Event:
release
-
Statement type: