Skip to main content

Semantic failure memory for AI agents

Project description

openfossil

Python SDK for FOSSIL — semantic failure memory for AI agents.

Install

# with local embedder (recommended, no API key needed)
pip install openfossil[local]

# core only — bring your own embedder or use remote API
pip install openfossil

# with OpenAI embedder
pip install openfossil[openai]

Quickstart

from fossil import Fossil, FailureType, ResolutionType, Severity, TaskDomain

# local SQLite store — zero config
fossil = Fossil()

# point at the live community API
fossil = Fossil(api_url="https://fossil-api.hello-76a.workers.dev")

# record a failure after it happens
fossil.record(
    situation="agent extracting JSON from LLM output that returned markdown-fenced text",
    failure_type=FailureType.FORMAT_FAILURE,
    failure="json.loads() raised JSONDecodeError — model wrapped output in ```json fences",
    severity=Severity.MAJOR,
    resolution_type=ResolutionType.INPUT_SANITIZATION,
    resolution="strip markdown fences with regex before parsing",
    framework="langchain",
    model="llama-3.3-70b-versatile",
    domain=TaskDomain.DATA_ANALYSIS,
    verified=True,
)

# search before a task step
results = fossil.search("parsing structured data from LLM text output")
for record, score in results:
    print(f"{score:.2f}{record.resolution.description}")

CLI

# record a failure interactively
fossil record

# search for similar past failures
fossil search "JSON parsing failure"

# search against the live API
fossil search "JSON parsing failure" --api-url https://fossil-api.hello-76a.workers.dev

# list recent fossils
fossil list

# check connection
fossil ping

Inject into agent context

from fossil import Fossil, format_for_injection

fossil = Fossil()

def run_step(task: str, system_prompt: str) -> str:
    results = fossil.search(task, top_k=3, min_score=0.5)
    fossil_context = format_for_injection(results)
    augmented_prompt = system_prompt + "\n\n" + fossil_context
    # pass augmented_prompt to your LLM call
    ...

format_for_injection returns a string you drop directly into any system prompt or context window. No framework lock-in.

Remote store

from fossil import Fossil

fossil = Fossil(api_url="https://fossil-api.hello-76a.workers.dev")
fossil.record(...)
results = fossil.search(...)

No local embedder needed when using the remote store — embeddings run on the API side.

Custom embedder

from fossil import Fossil
from fossil.embedder import OpenAIEmbedder

embedder = OpenAIEmbedder(model_name="text-embedding-3-small", api_key="sk-...")
fossil = Fossil(embedder=embedder)

Custom store location

fossil = Fossil(db_path="/path/to/my/fossil.db")

Context manager

with Fossil() as fossil:
    fossil.record(...)
    results = fossil.search(...)

SDK API

Method Description
fossil.record(...) Record a failure + resolution
fossil.search(situation, top_k, min_score, domain) Semantic similarity search
fossil.get(id) Fetch a single record
fossil.delete(id) Delete a record
fossil.list(limit, offset) Paginate all records
fossil.count() Total records in store

Failure types

misinterpretation hallucinated_tool format_failure context_loss infinite_loop premature_termination scope_creep ambiguity_paralysis tool_misuse adversarial_input compounding_error

Resolution types

prompt_change tool_fix retry human_override context_injection schema_correction step_decomposition input_sanitization

Running tests

cd packages/sdk-python
pip install -e ".[dev,local]"
pytest

First run downloads the embedding model (~80MB, cached after that).

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

openfossil-0.1.8.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

openfossil-0.1.8-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file openfossil-0.1.8.tar.gz.

File metadata

  • Download URL: openfossil-0.1.8.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for openfossil-0.1.8.tar.gz
Algorithm Hash digest
SHA256 4a2e72e25a2444dfddebe1ee7fbaccd201748a2246f07fb18f40167d2aa8a6ab
MD5 a587511d23a3065bb19409fb3ec6e47b
BLAKE2b-256 562957331fb38b339610ea59815828e56960cfbbb75b4d8b83ea74be7a525291

See more details on using hashes here.

File details

Details for the file openfossil-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: openfossil-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for openfossil-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 902d0272a908159e729a4d6d0ca501889fc365e7c1b1894eb5f61a27eafa2fc6
MD5 4746813e97ade8aeb5b6169f179d1149
BLAKE2b-256 10a04cd30a36a8771f96e6dc7b56df86f20ccf0032b30c2f5f791c32b3c63123

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