Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
"""Stable hashes for task inputs and conditional file writes."""
from __future__ import annotations
import hashlib
import json
from typing import Any
def digest(value: Any) -> str:
"""Hash JSON-compatible task inputs deterministically, including their versions."""
return hashlib.sha256(
json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()
).hexdigest()
def content_hash(value: str | bytes) -> str:
"""Return the byte hash used by conditional content writes."""
return hashlib.sha256(value.encode() if isinstance(value, str) else value).hexdigest()