Cognee

Cognee is an open-source memory engine with a semantic graph at its core that provides observability for AI agents and semantic workflows. The Cognee–Respan integration patches Cognee’s @observe decorator so every task and workflow run becomes a Respan span automatically.

Create an account at platform.respan.ai and grab an API key.

Run npx @respan/cli setup to set up with your coding agent.

Setup

1

Install packages

$pip install respan-ai cognee-community-observability-respan
2

Set environment variables

$export MONITORING_TOOL="respan"
$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
$export LLM_API_KEY="YOUR_OPENAI_API_KEY"

MONITORING_TOOL=respan tells Cognee to use Respan as its observability backend. LLM_API_KEY is required if your pipeline calls LLMs.

3

Initialize and run

1import asyncio
2import cognee_community_observability_respan # noqa: F401 — patches Cognee on import
3from cognee.modules.observability.get_observe import get_observe
4
5observe = get_observe() # returns Respan-backed decorator
6
7@observe
8def process_documents(documents: list[str]):
9 return [f"Processed: {doc}" for doc in documents]
10
11@observe
12def create_knowledge_graph(processed_docs: list[str]):
13 return [{"id": i, "content": doc} for i, doc in enumerate(processed_docs)]
14
15@observe(workflow=True)
16async def semantic_workflow():
17 documents = ["Document 1", "Document 2", "Document 3"]
18 processed = process_documents(documents)
19 return create_knowledge_graph(processed)
20
21result = asyncio.run(semantic_workflow())
22print(f"Created knowledge graph with {len(result)} nodes")
4

View your trace

Open the Traces page to see your Cognee workflow with task spans, knowledge graph operations, and LLM calls.

How it works

The Respan integration patches Cognee’s get_observe() at import time so:

  • @observe maps to Respan’s task() decorator.
  • @observe(workflow=True) maps to Respan’s workflow() decorator.
  • Telemetry is initialized once via RespanTelemetry() on import.

Configuration

VariableDescriptionRequired
MONITORING_TOOLSet to respanYes
RESPAN_API_KEYYour Respan API keyYes
LLM_API_KEYYour LLM provider API keyOptional

Custom span names

1@observe(name="custom_task_name")
2def my_task():
3 pass
4
5@observe(workflow=True, name="custom_workflow_name")
6async def my_workflow():
7 pass

Troubleshooting

IssueSolution
No tracesEnsure RESPAN_API_KEY is set and MONITORING_TOOL=respan.
Decorators don’t fireImport cognee_community_observability_respan before calling get_observe().