Skip to main content

Microsoft Agent Framework integration for Hindsight - persistent memory for AI agents

Project description

hindsight-agent-framework

Persistent long-term memory for Microsoft Agent Framework via Hindsight.

Microsoft Agent Framework is the successor to Semantic Kernel. This integration plugs Hindsight in as a context provider, so every agent run automatically recalls relevant memories into the agent's context and retains the conversation afterward — no MCP, and no tools the model has to remember to call.

Installation

pip install hindsight-agent-framework

Recommended: Hindsight Cloud — sign up free, get an API key, and skip self-hosting.

Usage

from agent_framework.openai import OpenAIChatClient
from hindsight_agent_framework import HindsightProvider

agent = OpenAIChatClient().as_agent(
    name="assistant",
    instructions="You are a helpful assistant.",
    context_providers=[HindsightProvider(bank_id="user-123")],
)

session = agent.create_session()
await agent.run("Remember that I prefer vegetarian food.", session=session)
# ...later, even in a new process:
await agent.run("Suggest a recipe.", session=session)  # recalls the preference

Set your API key once via the HINDSIGHT_API_KEY environment variable, or pass api_key=/hindsight_api_url= to HindsightProvider. For self-hosting:

pip install hindsight-all
export HINDSIGHT_API_LLM_API_KEY=your-openai-key
hindsight-api  # http://localhost:8888
HindsightProvider(bank_id="user-123", hindsight_api_url="http://localhost:8888")

How It Works

Hook Behavior
before_run Recall memories relevant to the user's message and inject them as a ## Memories block in the agent's instructions.
after_run Retain the user input + agent response so future runs build on them.

Memories live in a Hindsight bank (one per user/agent/session — you choose). Recall and retain are best-effort: a memory hiccup never blocks the agent.

Configuration

HindsightProvider(bank_id, ...) accepts: client, hindsight_api_url, api_key, budget (low/mid/high), max_tokens, context, tags, recall_tags, recall_tags_match, mission (creates the bank with a fact-extraction persona), auto_recall, auto_retain, source_id. You can also set process-wide defaults via configure(...).

Development

uv sync
uv run ruff check .
uv run pytest tests -v          # unit tests
uv run pytest tests -v -m requires_real_llm   # e2e (needs a live Hindsight server)

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

hindsight_agent_framework-0.1.0.tar.gz (92.0 kB view details)

Uploaded Source

Built Distribution

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

hindsight_agent_framework-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hindsight_agent_framework-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e1cc8dfa1b2e3eed5b70266e4f50360dc63f55d7722e3e7f3088e2e3d6f071b6
MD5 36cd5efadedd2e2f0316fd75b2c7f277
BLAKE2b-256 09315adc199ea7be1b18113940b750411b08ac307fd5a5d90568549750a89273

See more details on using hashes here.

Provenance

The following attestation bundles were made for hindsight_agent_framework-0.1.0.tar.gz:

Publisher: release-integration.yml on vectorize-io/hindsight

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for hindsight_agent_framework-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e44f81037e570100332414ddba34a39759393aaea82bcba1b7928d46d91c682
MD5 e4f2814cd163bb625e220da1adbae88e
BLAKE2b-256 d189b6087f9a242ccb228be9df8d1a32f69c4468b740fa501d3a75abf70cc0cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for hindsight_agent_framework-0.1.0-py3-none-any.whl:

Publisher: release-integration.yml on vectorize-io/hindsight

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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