AutoGen Integration
Add persistent memory to AutoGen agent workflows with Papr retrieval before response generation and writeback after each turn.
What You Build
- Conversation-aware retrieval for each agent turn
- Persistent memory for decisions and outcomes
- User-scoped context that survives session restarts
Prerequisites
- Papr API key in
PAPR_MEMORY_API_KEY - AutoGen runtime where pre-turn and post-turn hooks are available
- Stable
external_user_idfrom your app identity model
Integration Pattern
- Retrieve relevant memory before the agent replies.
- Inject memory context into the prompt or system state.
- Store the resulting decision summary after the turn.
Minimal Setup
- Add a pre-turn retrieval helper in your AutoGen flow.
- Add a post-turn writeback helper for decision summaries.
- Run a multi-turn session and verify continuity.
Python Skeleton
import os
from papr_memory import Papr
client = Papr(x_api_key=os.environ.get("PAPR_MEMORY_API_KEY"))
def retrieve_context(prompt: str, external_user_id: str):
return client.memory.search(
query=prompt,
external_user_id=external_user_id,
enable_agentic_graph=True,
max_memories=20,
max_nodes=15,
)
def store_turn(summary: str, external_user_id: str):
return client.memory.add(
content=summary,
external_user_id=external_user_id,
metadata={"role": "assistant", "category": "decision"},
memory_policy={"mode": "auto"},
)Validation Checklist
- Memory retrieval runs before every AutoGen turn
- Turn summaries become searchable in subsequent turns
- Retrieval quality improves over repeated workflows
Troubleshooting
If turn memory is missing, verify writeback executes after each turn and check Error Playbook.