Skip to main content

hindsight-google-adk

Persistent long-term memory for Google ADK agents via Hindsight.

The package gives you two complementary patterns:

  • HindsightMemoryService — Implements ADK's BaseMemoryService. Pass it to Runner(memory_service=...) and sessions are automatically retained on completion; agents calling search_memory get results back from Hindsight.
  • create_hindsight_tools(...) — Returns a list of ADK FunctionTool instances (hindsight_retain, hindsight_recall, hindsight_reflect) the model can call inside a turn.

Installation

pip install hindsight-google-adk

Quick Start: Automatic Memory

import asyncio
from google.adk.agents import LlmAgent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

from hindsight_google_adk import HindsightMemoryService

memory = HindsightMemoryService.from_url(
    hindsight_api_url="https://api.hindsight.vectorize.io",
    api_key="hsk_...",
)

agent = LlmAgent(name="assistant", model="gemini-2.0-flash")

runner = Runner(
    app_name="my-app",
    agent=agent,
    session_service=InMemorySessionService(),
    memory_service=memory,
)

When a session ends, Runner calls add_session_to_memory, which retains the session's events to a Hindsight bank keyed by (app_name, user_id). When the agent (or another call) invokes search_memory(app_name, user_id, query), the integration runs a Hindsight recall and returns the results as ADK MemoryEntry objects.

Quick Start: Explicit Tools

from google.adk.agents import LlmAgent
from hindsight_google_adk import create_hindsight_tools

tools = create_hindsight_tools(
    bank_id="user-123",
    hindsight_api_url="https://api.hindsight.vectorize.io",
    api_key="hsk_...",
)

agent = LlmAgent(name="assistant", model="gemini-2.0-flash", tools=tools)

The agent now has three tools (toggle with include_retain / include_recall / include_reflect):

  • hindsight_retain(content) — store information to long-term memory
  • hindsight_recall(query) — search memory and return matches
  • hindsight_reflect(query) — synthesize a coherent answer from memory

Global Configuration

For shared defaults, call configure(...) once at startup:

from hindsight_google_adk import configure

configure(
    hindsight_api_url="https://api.hindsight.vectorize.io",
    api_key=None,                      # falls back to HINDSIGHT_API_KEY env var
    bank_id_template="{app_name}::{user_id}",
    budget="mid",
    max_tokens=4096,
)

Subsequent HindsightMemoryService.from_url() and create_hindsight_tools() calls use the global config as a fallback.

Bank ID Derivation

By default, each (app_name, user_id) pair gets its own bank: "{app_name}::{user_id}". Override with bank_id_template:

# Per-user bank shared across apps
HindsightMemoryService.from_url(..., bank_id_template="user::{user_id}")

# Static bank shared across all users
HindsightMemoryService.from_url(..., bank_id_template="my-shared-bank")

Configuration Reference

Argument Default Description
hindsight_api_url https://api.hindsight.vectorize.io Hindsight API URL (Cloud by default).
api_key HINDSIGHT_API_KEY env Bearer token for Hindsight Cloud.
bank_id_template "{app_name}::{user_id}" Format string for deriving the bank id.
budget "mid" Recall budget: low/mid/high.
max_tokens 4096 Max tokens for recall results.
tags None Extra tags added to retains. app: and user: are always added.
recall_tags None Extra tags appended to recall queries. user: is always added.
recall_tags_match "any" Tag match mode: any / all / any_strict / all_strict.
mission None If set, the bank is created (idempotent) on first use with this fact-extraction mission.
context "google-adk" Provenance label attached to retained content.

Memory Scoping with Tags

Each retained session/event carries app:<app_name> and user:<user_id> tags. Recall queries automatically include user:<user_id> so users never see each other's memories. Pass tags=[...] to extend the retain set or recall_tags=[...] to filter recall further.

Connection Modes

HindsightMemoryService.from_url(
    hindsight_api_url="https://api.hindsight.vectorize.io",
    api_key="hsk_...",
)

Self-hosted

HindsightMemoryService.from_url(hindsight_api_url="http://localhost:8888")

Error Handling

All add_* and search_memory methods are resilient: Hindsight failures are logged but never propagate to the Runner. The explicit tools raise HindsightError on failure so the agent can react.

Requirements

  • Python 3.10+
  • google-adk>=2.0
  • hindsight-client>=0.4.0

License

MIT

Metadata

Release files for hindsight-google-adk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hindsight-google-adk 0.1.0
File Size Uploaded Provenance Actions
hindsight_google_adk-0.1.0.tar.gz 164.5 kB With provenance Details for hindsight_google_adk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hindsight-google-adk 0.1.0
File Interpreter ABI Platform Actions
hindsight_google_adk-0.1.0-py3-none-any.whl Python 3 none any Details for hindsight_google_adk-0.1.0-py3-none-any.whl

Total release size: 177.2 kB

Release files / hindsight_google_adk-0.1.0.tar.gz

Download URL hindsight_google_adk-0.1.0.tar.gz
Size 164.5 kB
Tags Source
SHA-256 checksum
How to use checksums
edfdaa497f7ddd87179d710ec987c7795dd36be9ff43c4b60b901ed08da56903
BLAKE2b-256 checksum
How to use checksums
908dda110b0db2e7830e8c381156c4fb0ccadff86d765a4f8fbdc2cdde5707aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2026.

Transparency log

Release files / hindsight_google_adk-0.1.0-py3-none-any.whl

Download URL hindsight_google_adk-0.1.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7508f7aa768b591d06d245a3891be3ada18e30a0a4faebf5c770f38a5a972d51
BLAKE2b-256 checksum
How to use checksums
548d600fe20bcf2e797dc36d0fc0492ac70c1a40a9cbc2b339bd9d4d41ca0321
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2026.

Transparency log

Security for hindsight-google-adk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hindsight_google_adk-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page