Skip to main content

Microsoft AutoGen integration for MCAL - Goal-aware memory for multi-agent systems

Project description

mcal-ai-autogen

Microsoft AutoGen integration for MCAL (Memory-Context Alignment Layer), bringing goal-aware memory to AutoGen agents.

Installation

pip install mcal-ai-autogen

# With AutoGen dependencies
pip install mcal-ai-autogen[autogen]

Quick Start

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from mcal import MCAL
from mcal_autogen import MCALMemory

# Initialize MCAL
mcal = MCAL(llm_provider="openai")

# Create MCAL-backed memory
memory = MCALMemory(mcal, user_id="user_123")

# Create an agent with MCAL memory
model_client = OpenAIChatCompletionClient(model="gpt-4")
agent = AssistantAgent(
    name="data_engineer",
    model_client=model_client,
    memory=[memory],
    system_message="You are a helpful data engineering assistant.",
)

# Use the agent — MCAL automatically tracks context and decisions
result = await agent.run(task="How should I set up my ETL pipeline?")

What's New in 0.2.8

  • Configurable Extraction Profiles — Choose decision (rationale/alternatives/trade-offs), conversational (preferences/relationships), or comprehensive (both)
  • Hybrid Retrieval with ChunkStore — Graph traversal + embedding search for maximum recall
  • FACT/PERSON Node Protection — Graph compaction preserves factual and identity nodes
  • Benchmark Results — Decision profile achieves 93.3% detail retention, 62% token reduction in 150-turn CTO advisor tests
# New v0.2.8 — pass extraction options to MCAL
mcal = MCAL(
    llm_provider="anthropic",
    extraction_profile="decision",
    enable_chunk_store=True,
)
memory = MCALMemory(mcal, user_id="user_123")

Features

Goal-Aware Memory

MCAL's unique value is understanding your project's goals and maintaining context across conversations:

mcal = MCAL(llm_provider="anthropic")
memory = MCALMemory(mcal)

# Add relevant context
from autogen_core.memory import MemoryContent
await memory.add(MemoryContent(
    content="We decided to use Kafka for streaming",
    mime_type="text/plain",
    metadata={"category": "architecture", "decision": True}
))

# Query returns goal-relevant results
results = await memory.query("What messaging system should I use?")
# Returns Kafka decision with goal-relevance scoring

Decision Tracking

Track architectural and project decisions automatically:

memory = MCALMemory(
    mcal,
    enable_goal_tracking=True,  # Extract goals from content
    include_decisions=True,      # Include decisions in search
)

# Decisions are automatically tracked
await memory.add(MemoryContent(
    content="After evaluating options, we chose PostgreSQL for its JSON support",
    mime_type="text/plain"
))

# Query finds relevant decisions
results = await memory.query("database selection")

User Isolation

Support multi-tenant scenarios with user isolation:

# Create separate memories for different users
user1_memory = MCALMemory(mcal, user_id="alice")
user2_memory = MCALMemory(mcal, user_id="bob")

# Each user has isolated memory
await user1_memory.add(MemoryContent(content="Alice prefers Python"))
await user2_memory.add(MemoryContent(content="Bob prefers Rust"))

# Queries only return user-specific results
results = await user1_memory.query("language preference")
# Only returns Alice's preference

TTL Support

Configure time-to-live for memory entries:

memory = MCALMemory(mcal, default_ttl_minutes=60)  # 1 hour default

# Or per-entry TTL via metadata
await memory.add(MemoryContent(
    content="Temporary context",
    mime_type="text/plain",
    metadata={"ttl_minutes": 15}  # 15 minute TTL
))

Thread Safety

All operations are protected by RLock — safe for concurrent access from multiple agents.

Integration with AutoGen Features

With AssistantAgent

from autogen_agentchat.agents import AssistantAgent

agent = AssistantAgent(
    name="assistant",
    model_client=model_client,
    memory=[memory],  # MCAL memory integrates seamlessly
)

With Teams

from autogen_agentchat.teams import RoundRobinGroupChat

# Share MCAL memory across team members
shared_memory = MCALMemory(mcal, user_id="team_alpha")

coder = AssistantAgent("coder", model_client=model_client, memory=[shared_memory])
reviewer = AssistantAgent("reviewer", model_client=model_client, memory=[shared_memory])

team = RoundRobinGroupChat([coder, reviewer])

Context Window Management

MCAL automatically manages context relevance:

memory = MCALMemory(
    mcal,
    max_results=10,           # Limit results per query
    score_threshold=0.5,      # Minimum relevance score
)

# update_context adds relevant memories to the agent's context
result = await memory.update_context(model_context)

API Reference

MCALMemory

class MCALMemory(Memory):
    def __init__(
        self,
        mcal: MCAL,
        user_id: str = "default",
        name: str = "mcal_memory",
        max_results: int = 10,
        score_threshold: float = 0.0,
        default_ttl_minutes: Optional[float] = None,
        enable_goal_tracking: bool = True,
        include_decisions: bool = True,
    ): ...

Key Methods

Method Async Description
add(content) Add MemoryContent to memory
query(query) Search for relevant memories, returns MemoryQueryResult
update_context(model_context) Update agent context with relevant memories
clear() Clear all memory entries
close() Cleanup resources

Helper Methods

Method Description
add_text(text, metadata=None) Convenience wrapper for adding plain text
query_text(query) Convenience wrapper returning list of strings
item_count Property returning number of stored items
get_all_items() Return all non-expired memory items

Requirements

  • Python >= 3.11
  • mcal-ai >= 0.2.0
  • autogen-core >= 0.4.0 (optional — gracefully degrades if not installed)
  • autogen-agentchat >= 0.4.0 (optional)

License

MIT License

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_autogen-0.2.8.tar.gz (14.2 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_autogen-0.2.8-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file mcal_ai_autogen-0.2.8.tar.gz.

File metadata

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

File hashes

Hashes for mcal_ai_autogen-0.2.8.tar.gz
Algorithm Hash digest
SHA256 4fdba68384576ef92e770bda5b356ff6a798bc492d80ab23f3a63576fa62a25f
MD5 876a61caeeda4bcfebc2d1660d16956a
BLAKE2b-256 dd0b65789e6601a6d2712d183b104a1ca05f2b603b1ac196f1dea14d99136b2c

See more details on using hashes here.

File details

Details for the file mcal_ai_autogen-0.2.8-py3-none-any.whl.

File metadata

File hashes

Hashes for mcal_ai_autogen-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a9f88ab3002c92b984cf38efe49fa2d57e60657972d3b6aac739afde860e3ed1
MD5 0aa03db4fb4c535d328035de76d1bd9f
BLAKE2b-256 f9c6f35644f612990c0b6ec121e7b4ee34ae3224d8ab01b96bca9d570fb66b7f

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