API Reference

BeliefTracker

The main orchestrator class.

MethodReturnsDescription
wrap(fn)CallableDecorator that intercepts LLM calls for belief extraction
set_session(id)NoneSet the active session ID for tracking
set_conversation(id)NoneSet the active conversation thread within a session
get_context_prompt()strGet formatted belief summary for injection into prompts
get_beliefs(session_id)list[Belief]Retrieve all beliefs for a session
delete_session(id)DeletionReceiptDelete all session data (GDPR)
prune_expired_beliefs()intRemove beliefs older than max_age_seconds
update_belief_reference()NoneTouch a belief's last_referenced_at timestamp

ProviderAdapter (Protocol)

Interface that all adapters implement.

MethodReturnsDescription
to_llm_call(*args, **kwargs)LLMCallConvert native SDK args to universal LLMCall
to_llm_response(response)LLMResponseConvert native SDK response to universal LLMResponse
generate(call, response_format)LLMResponseExecute generation with retry and timeout
get_embedding(text)list[float]Generate embedding for a single text
get_embeddings(texts)list[list[float]]Generate embeddings for multiple texts (batched)
health_check()boolVerify provider connectivity

Store (Protocol)

Interface for belief storage backends.

MethodReturnsDescription
add_belief(session_id, belief)NoneAdd or overwrite a belief
get_beliefs(session_id, conversation_id)list[Belief]Retrieve all beliefs for a session
search_beliefs(session_id, embedding, ...)list[Belief]Semantic similarity search
remove_belief(session_id, subject, predicate)NoneRemove a specific belief
update_belief(session_id, belief)NoneUpdate an existing belief
clear(session_id)NoneClear all beliefs for a session

Key Models

ClassModuleDescription
Beliefbeliefstate.modelsSubject-predicate-value triple with confidence and metadata
LLMCallbeliefstate.callUniversal representation of an LLM chat completion request
LLMResponsebeliefstate.callUniversal representation of an LLM chat completion response
TrackerConfigbeliefstate.configPydantic configuration model for the tracker
DeletionReceiptbeliefstate.modelsAudit receipt returned by session deletion
RetryConfigbeliefstate.adapters.commonPer-adapter retry strategy configuration

Changelog

v0.1.0 — Initial Release

  • Core belief extraction pipeline (extract → detect → resolve)
  • 5 provider adapters: OpenAI, Anthropic, Gemini, Ollama, LiteLLM
  • 3 storage backends: SQLite, Redis, In-Memory
  • 7 framework integrations: FastAPI, Flask, ASGI, WSGI, LangChain, LlamaIndex, OpenAI Assistants
  • Dual-Adapter architecture for cost optimization
  • Pluggable dispatchers: asyncio, sync, Celery, RQ
  • Production resilience: retry, circuit breaker, health checks
  • OpenTelemetry observability
  • GDPR session deletion with audit receipts
  • Token-aware belief injection
  • Staleness scoring for session resumption
  • Full mypy type safety (0 errors)
  • 205 unit tests