Skip to content

feat(pydantic-ai): HindsightMemory capability and Pydantic AI 2.x support - #7202

Merged
nicoloboschi merged 2 commits into
mainfrom
wip/1202-00e1
Dec 2, 2026
Merged

nicoloboschi merged 2 commits into
mainfrom
wip/1202-00e1

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Closes #7161

What changes

One object for memory. HindsightMemory is a Pydantic AI capability: it gives the agent the memory tools and, on every run, recalls relevant memories into its instructions. Bank, client, tags and budget are set once and used by both.

agent = Agent("openai:gpt-4o", capabilities=[HindsightMemory(client=client, bank_id="user-123")])

Flags pick what it adds: retain, recall, reflect (tools) and auto_recall (instructions). create_hindsight_tools and memory_instructions are unchanged; the capability is built from them.

Pydantic AI 2.x. The code already worked on 2.x, but nothing tested it. CI now runs the tests on the locked 1.x, on the new floor 1.71.0, and on 2.x. New tests run a real Agent with Pydantic AI's TestModel (no network), so a Pydantic AI change that breaks the wiring fails CI.

The floor moves from 1.0.0 to 1.71.0, the first release with capabilities. Built on AbstractCapability rather than the newer Capability helper, which only exists after 1.100.

Docs. The capability is the main example on the integration page and README. Pydantic AI joins the "Frameworks & SDKs" sidebar preview, and the gallery card no longer says "dependency injection".

Not in this PR

  • bank_id taken from the run context (one agent, many users) — add when someone needs it.
  • A hook that retains every run's output.
  • The cookbook page copies an app from the hindsight-cookbook repo; it changes there.

…t, docs

- HindsightMemory: one Pydantic AI capability that adds the memory tools and
  auto-recalled memories, configured once (bank, client, tags, budget)
- Floor pydantic-ai-slim at 1.71.0 (first release with capabilities)
- CI runs the tests on the locked 1.x, the 1.71.0 floor and 2.x
- Tests that run a real Agent with TestModel
- Docs: capability as the main example, Pydantic AI in the Frameworks & SDKs
  sidebar preview, fixed gallery description

Closes #7161
@nicoloboschi nicoloboschi added the integration A framework integration without its own label label Dec 2, 2026
Review fixes:
- HindsightMemory resolves recall_tags from configure() once, so the recall
  tool and auto-recall filter the same way (memory_instructions never read
  the global config); test added
- Comment why it builds on AbstractCapability and sets id directly
- recall_tags docstring names the configure() fallback
@nicoloboschi
nicoloboschi merged commit b2034e0 into main Dec 2, 2026
231 of 232 checks passed
@nicoloboschi
nicoloboschi deleted the wip/1202-00e1 branch December 2, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration A framework integration without its own label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pydantic AI integration: surface it in the docs, add a memory capability, and support Pydantic AI 2.x

1 participant