Last updated

CrewAI Integration

Use Papr as shared memory across CrewAI tasks so agents can reuse prior findings and maintain continuity.

What You Build

  • Shared memory retrieval before task execution
  • Post-task writeback of outcomes and learnings
  • User and tenant scoped memory boundaries

Prerequisites

  • Papr API key in PAPR_MEMORY_API_KEY
  • CrewAI project with task lifecycle hooks
  • Stable per-user identifier mapped to external_user_id

Integration Pattern

  1. Search Papr with the task objective.
  2. Pass retrieved context to the active CrewAI agent.
  3. Write task outcomes back to Papr memory.

Minimal Setup

  1. Add pre-task retrieval to your crew execution flow.
  2. Add post-task writeback after task completion.
  3. Validate with repeated tasks for the same user scope.

Python Skeleton

import os
from papr_memory import Papr

client = Papr(x_api_key=os.environ.get("PAPR_MEMORY_API_KEY"))


def pre_task_context(task_prompt: str, actor_id: str):
    return client.memory.search(
        query=task_prompt,
        external_user_id=actor_id,
        enable_agentic_graph=True,
        max_memories=20,
        max_nodes=15,
    )


def post_task_learning(outcome: str, actor_id: str):
    return client.memory.add(
        content=outcome,
        external_user_id=actor_id,
        metadata={"role": "assistant", "category": "learning"},
        memory_policy={"mode": "auto"},
    )

Validation Checklist

  • Task startup includes retrieved Papr context
  • Task output is persisted and searchable
  • Shared memory improves multi-step workflows

Troubleshooting

If outcomes are not reused, verify post-task writes and check scope fields using Error Playbook.