Files
Ben f5a6c300f1 feat(agent-framework): Hindsight memory for Microsoft Agent Framework (no MCP) (#1989)
* feat(agent-framework): add Hindsight memory integration via context provider

Persistent memory for Microsoft Agent Framework (the successor to Semantic
Kernel) without MCP. HindsightProvider is a ContextProvider whose before_run
recalls relevant memories and injects them into the agent's instructions, and
whose after_run retains the conversation. Reuses the LlamaIndex integration's
client/config pattern and the hindsight-client Python SDK.

Targets the agent-framework-core 1.x before_run/after_run + SessionContext
contract (verified against the installed package since the API has churned).
15 unit tests subclass the real ContextProvider so drift fails loudly, plus a
gated e2e. Includes CI job, release + changelog + docs wiring, and an icon.

* chore(agent-framework): refresh lock to agent-framework-core 1.8.1 (verified no API drift)

* fix(agent-framework): drop unused per-op timeout constants

TIMEOUT_RETAIN/TIMEOUT_RECALL/TIMEOUT_BANK were defined but never used: the
hindsight-client SDK sets one timeout on the constructor and has no per-call
timeout argument, so per-op values can't be wired in. Keep the single
constructor-level TIMEOUT_DEFAULT and document why. Addresses review feedback.
2026-06-11 13:57:20 -04:00

2.6 KiB

sidebar_position, title, description
sidebar_position title description
8 Microsoft Agent Framework Persistent Memory with Hindsight | Integration Guide Add persistent memory to Microsoft Agent Framework agents with Hindsight via a context provider. Recalls relevant context before each run and retains the conversation after — no MCP, no tools to call.

Microsoft Agent Framework

View Changelog →

Persistent memory for Microsoft Agent Framework — the successor to Semantic Kernel — using Hindsight. The integration plugs 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.

Quick Start

:::tip Recommended: Hindsight Cloud Sign up free for a Hindsight Cloud API key — no self-hosting required. :::

pip install hindsight-agent-framework
export HINDSIGHT_API_KEY=your-hindsight-key
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)
await agent.run("Suggest a recipe.", session=session)  # recalls the preference

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, or session (you choose via bank_id). Recall and retain are best-effort: a memory hiccup never blocks the agent.

Configuration

HindsightProvider(bank_id, ...) accepts hindsight_api_url, api_key, budget (low/mid/high), max_tokens, tags, recall_tags, mission, auto_recall, auto_retain, and more. Process-wide defaults can be set with configure(...).

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")

See the integration source for full details.