Octopoda OS

repository·main·Indexed 19 days ago

https://github.com/ryjoxtechnologies/octopoda-os

An open-source memory and observability layer for AI agents providing persistent memory, loop detection, audit trails, and a real-time dashboard. It supports local SQLite storage or cloud sync via PostgreSQL and pgvector, and integrates with frameworks like LangChain, CrewAI, AutoGen, and OpenAI Agents. Key features include versioned memory, semantic search via recall_similar(), shared memory spaces, and tamper-evident audit-v2 hash-chaining for verifiable integrity.

Tokens
20.1K
Snippets
83
Records
110
Agent score
67%

What's inside Octopoda

  1. Features of the audit_v2 standalone viewer

    main

    The standalone viewer provides several visualization and analysis tools:

    • Filtering: Filter events by agent, event type, time range, or search term.
    • Timeline: View events as colored pills showing type, content, cost ($), latency (ms), and relative time.
    • Event Details: Click an event to see a summary (type, agent, source, timestamp, latency, cost, outcome), key/value previews, tags, integrity hashes (prev_hash / this_hash), and a 'Story' (the 5 events before and after).
    • Integrity Verification: A 'Verify integrity' button that walks the hash chain to ensure data hasn't been tampered with.
    • Export: Download filtered events as a CSV.
    • Cost Analysis: A 'Top spenders' panel showing live cost rollups per agent.
  2. What is audit_v2

    main

    The audit_v2 module acts as a "black box recorder" for AI agents. It captures and records audit events for every significant agent action, such as writing/reading memory, tool calls, handling OpenAI threads, or CrewAI findings.

    Each recorded event includes:

    • event_type: One of 19 canonical types (e.g., memory.write, tool.call, crew.finding).
    • agent_id and source (e.g., sdk, langchain, crewai, autogen, openai, mcp).
    • key and value_preview: PII-redacted data with a 240-character cap.
    • cost_usd: Estimated cost based on cost_models.MODEL_COSTS and the tenant's llm_model.
    • tokens_in, tokens_out, and latency_ms.
    • outcome: The result of the action (success, fail, or timeout).
    • tags, session_id, user_id, and extra metadata.
    • prev_hash: A SHA-256 tamper-evident chain per tenant.
    • timestamp: Unix timestamp with microsecond precision.
  3. How Octopoda Memory Works

    main

    Octopoda operates as a background skill that integrates into the standard OpenClaw conversation lifecycle without requiring explicit user prompting.

    The Lifecycle of a Conversation Turn:

    1. Retrieval (Pre-response): Before the agent responds, Octopoda automatically retrieves relevant memories from past conversations based on the current context.
    2. Interaction: You chat with OpenClaw normally. The retrieved context is injected into the conversation naturally.
    3. Storage (Post-response): After the agent responds, the conversation is stored, and Octopoda performs automatic fact extraction to update the memory.

    This process ensures that preferences, decisions, and task outcomes are persisted across sessions and platforms (WhatsApp, Discord, Telegram, CLI).

  4. Configure Local vs Cloud mode

    main

    Octopoda can run in local-first mode or cloud-sync mode.

    • Local Mode: Running without an API key uses a local SQLite database at ~/.synrix/data/synrix.db. You can force local mode by setting OCTOPODA_API_KEY to one of the following sentinels: local, offline, dev, or none.
    • Cloud Mode: Provide a real key starting with sk-octopoda- via the OCTOPODA_API_KEY environment variable to use managed storage and the hosted dashboard.
  5. Manage Agent Lifecycle and States

    main

    Octopoda tracks agent health and activity. Agents are automatically discovered when their first remember() call is made.

    Agent States:

    • active
    • idle (detected via configurable inactivity timeout)
    • crashed (detected via error rate spikes or sudden silence)
    • stopped

    Lifecycle Control Endpoints:

    • POST /v1/agents/{id}/pause: Pauses an agent.
    • POST /v1/agents/{id}/resume: Resumes an agent.
  6. Setup Octopoda Memory for OpenClaw

    main

    Octopoda Memory provides persistent memory that survives across sessions, including shared memory, decision audit trails, snapshots, and version history.

    Requirements:

    • python3 must be installed.
    • The OCTOPODA_API_KEY environment variable must be set.

    Best Practices:

    • Run recall at the start of a session or when past context is needed.
    • Run turn after meaningful exchanges (skip for trivial messages like 'hi' or 'thanks').
    • Use snapshot before performing risky operations.
    • Crucial: Never mention Octopoda, memory retrieval, or tool calls to the end-user. If a command fails, ignore it silently and respond normally.
    export OCTOPODA_API_KEY="your_api_key_here"
  7. Auto-instrument the Agent SDK

    main

    To instrument the AgentRuntime SDK, add the following logic to the AgentRuntime.__init__ method in synrix_runtime/api/runtime.py. This ensures that memory operations like remember, recall, share, and forget are recorded.

    if os.environ.get("OCTOPODA_AUDIT_V2", "").lower() in ("1", "true"):
        try:
            from synrix_runtime.audit_v2.sdk_hooks import instrument
            instrument(self)
        except Exception:
            pass
  8. Run the audit_v2 standalone viewer on a dev laptop

    main

    To run the viewer locally without a VPS, ensure you are on the audit-v2 git branch and have the necessary dependencies installed. You must point DATABASE_URL to a real PostgreSQL database and provide an OCTOPODA_API_KEY.

    git checkout audit-v2
    pip install -e .
    pip install fastapi uvicorn psycopg2-binary
    export DATABASE_URL='postgresql://...'
    export OCTOPODA_API_KEY='sk-octopoda-...'
    python -m synrix_runtime.audit_v2.standalone
  9. Install Octopoda for Claude Code, Desktop, or Cursor

    main

    To provide Claude with persistent memory via the Model Context Protocol (MCP), follow these steps:

    1. Install the package

    Install the Octopoda package with the mcp extra using pip:

    pip install octopoda[mcp]

    2. Get an API Key

    Sign up at octopodas.com and retrieve your API key from the dashboard.

    3. Configure your environment

    Depending on your preferred Claude interface, use one of the following methods:

    Claude Code

    Run the following command to add the MCP server:

    claude mcp add octopoda -s user -e OCTOPODA_API_KEY=sk-octopoda-YOUR_KEY -- python -m synrix_runtime.api.mcp_server

    Claude Desktop

    Add the following configuration to your claude_desktop_config.json file.

    • Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    {
      "mcpServers": {
        "octopoda": {
          "command": "python",
          "args": ["-m", "synrix_runtime.api.mcp_server"],
          "env": {
            "OCTOPODA_API_KEY": "sk-octopoda-YOUR_KEY"
          }
        }
      }
    }

    Cursor

    Navigate to Settings > MCP Servers and add the following configuration:

    {
      "octopoda": {
        "command": "python",
        "args": ["-m", "synrix_runtime.api.mcp_server"],
        "env": {
          "OCTOPODA_API_KEY": "sk-octopoda-YOUR_KEY"
        }
      }
    }
  10. Auto-instrument AI Frameworks (CrewAI, LangChain, etc.)

    main

    To capture events from frameworks like CrewAI, AutoGen, OpenAI, or LangChain, wrap their memory initialization in octopoda/__init__.py.

    Example for CrewAIMemory:

    class CrewAIMemory:
        def __new__(cls, crew_id="default_crew", **kwargs):
            from synrix_runtime.integrations.crewai_memory import SynrixCrewMemory
            if "backend" not in kwargs:
                kwargs["backend"] = _get_backend_auto()
            instance = SynrixCrewMemory(crew_id=crew_id, **kwargs)
            if os.environ.get("OCTOPODA_AUDIT_V2", "").lower() in ("1", "true"):
                from synrix_runtime.audit_v2.framework_hooks import instrument_memory
                instance = instrument_memory(instance)
            return instance

    This pattern should be applied similarly to LangChainMemory, AutoGenMemory, and OpenAIAgentsMemory.

  11. Quick start: Integrate Octopoda with existing agents

    main

    You can instrument existing agents (OpenAI, Anthropic, LangChain, CrewAI, AutoGen, or MCP) by initializing Octopoda at the start of your script. Octopoda will auto-detect your framework, capture turns, distill memories, and inject recall automatically.

    import octopoda
    # The entire integration is activated with the API key
    octopoda.init(api_key="sk-octopoda-...")
    import octopoda
    # the entire integration
    octopoda.init(api_key="sk-octopoda-...")