Skip to main content

Memory-Context Alignment Layer for Goal-Coherent AI Agents

Project description

MCAL: Memory-Context Alignment Layer

Intent-Preserving Memory for Goal-Coherent AI Agents

PyPI Python 3.11+ License: MIT

Why MCAL?

Current AI memory systems store facts but lose meaning:

What's Stored What's Lost
"User chose PostgreSQL" WHY they chose it over MongoDB
"User wants to visit Japan" HOW this fits their overall travel goals

MCAL preserves the reasoning behind decisions, not just the conclusions.

Installation

pip install mcal-ai

Framework integrations:

pip install mcal-ai-langgraph  # LangGraph integration
pip install mcal-ai-crewai     # CrewAI integration  
pip install mcal-ai-autogen    # AutoGen integration

Quick Start

import asyncio
from mcal import MCAL

async def main():
    mcal = MCAL(
        llm_provider="anthropic",     # or "openai", "bedrock"
        embedding_provider="openai",  # or "bedrock"
    )
    
    messages = [
        {"role": "user", "content": "I'm building a fraud detection pipeline"},
        {"role": "assistant", "content": "Let's start with data ingestion..."},
        {"role": "user", "content": "I chose PostgreSQL over MongoDB for storage"},
    ]
    
    # Extract goals, decisions, and reasoning
    result = await mcal.add(messages, user_id="user_123")
    print(f"Extracted {result.unified_graph.node_count} nodes")
    
    # Search with goal-aware retrieval
    results = await mcal.search("What database?", user_id="user_123")
    
    # Get context for LLM prompts
    context = mcal.get_context("What's next?", user_id="user_123")

asyncio.run(main())

Key Features

  • Intent Graph - Hierarchical goal structures (Mission → Goal → Task)
  • Reasoning Chains - Store WHY decisions were made, not just conclusions
  • Goal-Aware Retrieval - Retrieve based on objective alignment, not just similarity
  • Multi-Provider - Works with Anthropic, OpenAI, and AWS Bedrock
  • Standalone - No external dependencies, JSON file persistence

Environment Variables

# Choose your LLM provider
ANTHROPIC_API_KEY=sk-ant-...    # For Claude
OPENAI_API_KEY=sk-...           # For GPT-4 / embeddings

# Optional: AWS Bedrock
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_DEFAULT_REGION=us-east-1

Documentation

License

MIT License - see LICENSE for details.

Author

Created by Shiva Koreddi

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

mcal_ai-0.2.1.tar.gz (82.9 kB view details)

Uploaded Source

Built Distribution

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

mcal_ai-0.2.1-py3-none-any.whl (90.5 kB view details)

Uploaded Python 3

File details

Details for the file mcal_ai-0.2.1.tar.gz.

File metadata

  • Download URL: mcal_ai-0.2.1.tar.gz
  • Upload date:
  • Size: 82.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for mcal_ai-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4b8d0c0d5b324b2945eadc50404c2493dc2baf2de5964437cd20c71f10bb4522
MD5 f45c2662ec9cc91d9824e7ec3db9bbfb
BLAKE2b-256 2727928bb03748a11f21a048175fcce5f9a98ac29e513fd937610e1579f48727

See more details on using hashes here.

File details

Details for the file mcal_ai-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: mcal_ai-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 90.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for mcal_ai-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6968f2dc91dd63e4fe4c1f6cc798136fae67b77a897e6aac100962d47ee85364
MD5 8ba21f29f49125e87055f4f2c6d28093
BLAKE2b-256 72c06283efb4a34be9437c2df8751dee8fc3c645a1faed0c881f6b4af95b2c9c

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