Skip to main content

Cognee integration

Cognee is an open-source memory engine with a semantic graph at its core that provides observability for AI agents and semantic workflows. When integrated with Keywords AI, it offers comprehensive tracing and monitoring capabilities for complex AI systems.

Original resources

Cognee Documentation

Official integration guide for Keywords AI with Cognee

Cognee Blog

Deep dive into observability for semantic workflows

Key features

  • Single Decorator Observability: Use @observe to trace tasks and workflows
  • Pluggable Backends: Choose your monitoring tool via config or environment variables
  • Zero Vendor Lock-in: The interface remains the same regardless of the telemetry provider
  • Real-time Traces: Get logs and metrics across LLM calls and agent runs
  • Semantic 7Graph Integration: Built-in support for knowledge graph operations

Installation

Install the Keywords AI integration for Cognee:

Configuration

Set up your environment variables:

Quick Start

Prerequisites

  • Python 3.10+
  • Keywords AI API key (Get yours here)
  • LLM API key (e.g., OpenAI)
  • A clean virtual environment

Basic Usage

Complete Example

How It Works

Unified Abstraction

Cognee exposes a single surface for observability: @observe. This decorator works with:
  • Tasks: Decorate with @observe
  • Workflows: Decorate with @observe(workflow=True)

Backend Integration

The Keywords AI integration:
  1. Patches Cognee’s get_observe() at import time
  2. Maps @observe to Keywords AI’s task() decorator
  3. Maps @observe(workflow=True) to Keywords AI’s workflow() decorator
  4. Initializes telemetry via KeywordsAITelemetry() once on import

Monitoring Dashboard

Once configured, you can:
  1. Run your Cognee workflows with the @observe decorators
  2. Open your Keywords AI dashboard
  3. Inspect spans across tasks and workflows
  4. Monitor token usage, latency, and error rates
  5. Debug issues with detailed trace information

Advanced Configuration

Environment Variables

Custom Span Names

You can customize span names by providing additional parameters:

Community Integration

The Keywords AI integration is part of the cognee-community extension hub, which provides:
  • Independent Evolution: Adapters iterate at their own pace
  • Slim Installs: Pull in only what you need
  • Seamless Interoperability: Small registration shim wires into Cognee’s abstraction
  • Predictable Layout: Consistent provider patterns under packages/*

Troubleshooting

Common Issues

  1. Missing API Key: Ensure KEYWORDSAI_API_KEY is set
  2. Wrong Monitoring Tool: Verify MONITORING_TOOL=keywordsai
  3. Import Order: Import the integration package before using get_observe()

Debug Mode

Enable debug logging to troubleshoot issues: