Skip to main content

Persistent memory infrastructure for AI agents

Project description

Hystersis Python SDK

PyPI PyPI - Python Version

Persistent memory infrastructure for AI agents. Give your agents memory that adapts and compounds over time.

Why Use Hystersis SDK?

  • Simple - One-line installation, intuitive API
  • Powerful - Combine conversation history with knowledge graphs
  • Production-ready - Type hints, error handling, timeouts, retries
  • Async + Sync - Full async support with AsyncHystersis, sync wrapper with Hystersis
  • ProMem Extraction - 97%+ accuracy memory compression (PROPRIETARY)
  • Spreading Activation - +23% better multi-hop reasoning (PROPRIETARY)

Installation

pip install hystersis

With integrations:

pip install hystersis[integrations]

Quick Start

Sync Client

from hystersis import Hystersis

client = Hystersis(
    base_url="https://api.hystersis.ai",
    api_key="your-api-key"
)

# Check health
print(client.health())

# Create a session
session = client.create_session(agent_id="my-assistant")

# Add messages
client.add_message(session["id"], "user", "I love machine learning!")
client.add_message(session["id"], "assistant", "That's great! What type?")

# Search semantically
results = client.search("deep learning")

client.close()

Async Client

import asyncio
from hystersis import AsyncHystersis

async def main():
    async with AsyncHystersis(
        base_url="https://api.hystersis.ai",
        api_key="your-api-key"
    ) as client:
        session = await client.create_session(agent_id="my-assistant")
        memory = await client.create_memory(
            content="User likes ML",
            user_id="user-123"
        )
        results = await client.memories_search("deep learning")

asyncio.run(main())

Compression Engine

Hystersis includes a proprietary compression engine:

Metric Hystersis Mem0
Accuracy Retention 97%+ 91%
Token Reduction 80-85% 80%
Multi-hop Reasoning +23% baseline

Compression Control

from hystersis import Hystersis, CompressionMode

client = Hystersis(api_key="your-key")

# Set compression mode
client.compression_set_mode(CompressionMode.EXTRACT)
# Options: EXTRACT, BALANCED, AGGRESSIVE

# Get compression statistics
stats = client.compression_get_stats()
print(stats)

Compression Modes

Mode Accuracy Reduction Use Case
EXTRACT 97%+ 80-85% Maximum accuracy (default)
BALANCED 95%+ 85-90% General use
AGGRESSIVE 92%+ 90-93% Cost optimization

Tiered Memory

from hystersis import TierPolicy

client.tier_set_policy(TierPolicy.CONSERVATIVE)
# Options: AGGRESSIVE (1 day), BALANCED (7 days), CONSERVATIVE (30 days)

Enhanced Search

from hystersis import SearchMode

# Spreading Activation for complex queries
results = client.search_enhanced(
    "complex multi-hop query",
    mode=SearchMode.SPREADING
)

# Options: SPREADING (graph), VECTOR (fast), HYBRID (both)

API Reference

Initialization

from hystersis import Hystersis, AsyncHystersis

# Sync
client = Hystersis(
    base_url="https://api.hystersis.ai",
    api_key="your-key",
)

# Async
async with AsyncHystersis(base_url="...", api_key="...") as client:
    ...

Or use environment variables:

export HYSTERSIS_API_KEY="your-key"
client = Hystersis()  # Uses env var automatically

Sessions

session = client.create_session(agent_id="support-bot", metadata={"user": "123"})
client.add_message(session["id"], "user", "Hello!")
messages = client.get_messages(session["id"])

Memories

memory = client.create_memory(content="User likes Python", user_id="user-123")
memories = client.memories_list(user_id="user-123", limit=50)
results = client.memories_search("python programming", limit=10)

Entities & Knowledge Graph

entity = client.entities_create(name="Python", entity_type="Language")
client.relations_create(from_id=entity_a["id"], to_id=entity_b["id"], relation_type="RELATED_TO")
relations = client.entities_get_relations(entity["id"])

Skills

skill = client.skills_create(name="debugger", trigger="code error", action="analyze stack trace")
suggestions = client.skills_suggest(trigger="code error", context="python traceback")

Error Handling

from hystersis import (
    HystersisError,
    AuthenticationError,
    NotFoundError,
    ValidationError,
    RateLimitError,
)

try:
    client.create_session(agent_id="my-agent")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Too many requests")

Integrations

pip install hystersis[integrations]
# LangChain
from hystersis.integrations.langchain import HystersisMemory

# LlamaIndex
from hystersis.integrations.llamaindex import HystersisReader

# CrewAI
from hystersis.integrations.crewai import CrewMemory

# LangGraph
from hystersis.integrations.langgraph import HystersisChecker

# AutoGen
from hystersis.integrations.autogen import AutoGenMemory

Full Example

from hystersis import Hystersis, CompressionMode

with Hystersis(base_url="https://api.hystersis.ai", api_key="your-key") as client:
    # Create session
    session = client.create_session(agent_id="support-bot")

    # Store conversation
    client.add_message(session["id"], "user", "I can't access my dashboard")
    client.add_message(session["id"], "assistant", "I'll help you troubleshoot")

    # Create knowledge graph entity
    issue = client.entities_create(
        name="dashboard-access-issue",
        entity_type="Issue",
        properties={"status": "open"}
    )

    # Semantic search
    results = client.memories_search("dashboard access problems")

    # Enhanced search with spreading activation
    similar = client.search_enhanced(
        "permission denied dashboards",
        mode="spreading"
    )

    # Compression stats
    stats = client.compression_get_stats()
    print(f"Token reduction: {stats['token_reduction']*100}%")

Environment Variables

Variable Description
HYSTERSIS_API_KEY Default API key
AGENT_MEMORY_API_KEY Alias for API key (backward compat)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hystersis-0.1.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hystersis-0.1.0-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file hystersis-0.1.0.tar.gz.

File metadata

  • Download URL: hystersis-0.1.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hystersis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 19fc7d6863643bb8206281bb5027e87d9765380a39eac617930271503c5b32e0
MD5 970c5f503dd7f184f79eebbb3b4fc220
BLAKE2b-256 c6fb7f84de0e35f50b89a86fb9c87e2d0052820fb2596caf35e99ce5130858e5

See more details on using hashes here.

File details

Details for the file hystersis-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hystersis-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hystersis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59910acb70d6c2124dd92911b0ff2b08eecc8ff592ec63b12c586e564634633d
MD5 c0b3ee40e300517d7429797db2cffb50
BLAKE2b-256 3c488b4c9d30622618732855efabb8179d359924e0d503fc042d92a8dff625e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page