Skip to main content

Hindsight for GitHub Copilot CLI

Long-term memory for GitHub Copilot CLI — remembers your projects, preferences, and past sessions across every conversation, and gives subagents (explore, task, research, code-review, rubber-duck, security-review, custom agents) baseline project memory too.

How it works

Four Copilot CLI hooks keep memory in sync automatically:

Hook Action
sessionStart Recalls relevant memories (using the queued prompt, or a project-derived fallback query) and injects them as additionalContext
subagentStart Recalls memories for a spawned subagent (using the same fallback query — the payload never carries the subagent's specific task) and injects them as additionalContext
agentStop Retains the conversation to long-term memory every configured N turns
sessionEnd Forces a final retain (using the transcript path cached from the last agentStop) so short sessions are still stored

Limitations

Copilot CLI's userPromptSubmitted and preToolUse hooks do not support injecting additionalContext — only sessionStart, subagentStart, postToolUse, and notification can. That means recall happens once per session start (and once per subagent spawn), not before every prompt. If your session runs long, memories recalled at the start may go stale; a postToolUse-based per-turn refresh is a documented possible follow-up, not implemented here.

The built-in general-purpose subagent does not emit subagentStart/subagentStop — it never receives injected memory from this integration.

subagentStop (retaining each subagent's own transcript) is intentionally not implemented in v1 — it risks duplicating content already captured by the parent session's agentStop, and adds noisy memories for short-lived exploratory subagents.

Requirements

  • GitHub Copilot CLI with hooks support
  • Python 3.9+ (for hook scripts; stdlib only — no pip install required)
  • Hindsight: Hindsight Cloud or local hindsight-embed

Installation

Sign up free at ui.hindsight.vectorize.io for a Hindsight Cloud API key — or run a local server.

pip install hindsight-copilot-cli

Then run the installer once:

# Hindsight Cloud
hindsight-copilot-cli install --api-url https://api.hindsight.vectorize.io --api-token your-api-key

# Local daemon (hindsight-embed) — omit the flags
hindsight-copilot-cli install

The installer:

  1. Copies the hook scripts to ~/.copilot/hindsight-copilot-cli/scripts/ (or $COPILOT_HOME/hindsight-copilot-cli/scripts/ if COPILOT_HOME is set)
  2. Writes a standalone ~/.copilot/hooks/hindsight-copilot-cli.json with absolute paths to the scripts — Copilot CLI loads every *.json file in its hooks directory, so this never needs to merge with other tools' hook files
  3. Seeds ~/.hindsight/copilot-cli.json if it doesn't exist (drop your hindsightApiToken here later)

Restart Copilot CLI to load the hooks. If memories are not recalled or retained, check that ~/.copilot/hooks/hindsight-copilot-cli.json exists and that python3 is on $PATH from your shell.

Repo-scope install (shared team hooks)

To register the hooks at the repository level instead (.github/hooks/hindsight-copilot-cli.json, so a team can check in shared hook config):

hindsight-copilot-cli install --scope repo

The hook scripts are still installed once per machine under ~/.copilot; only the registration pointer is written to .github/hooks/hindsight-copilot-cli.json. Since that path is absolute and per-machine, every teammate needs to run the installer locally too. Never commit an API token — set HINDSIGHT_API_TOKEN in each environment instead.

Uninstall

hindsight-copilot-cli uninstall
# or, for a repo-scope install:
hindsight-copilot-cli uninstall --scope repo

This removes the hook scripts and the hindsight-copilot-cli.json registration file for the given scope. Your personal config at ~/.hindsight/copilot-cli.json is preserved.

Configuration

Default config lives in ~/.copilot/hindsight-copilot-cli/settings.json. For personal overrides stable across updates, create ~/.hindsight/copilot-cli.json:

{
  "hindsightApiUrl": "https://api.hindsight.vectorize.io",
  "hindsightApiToken": "your-api-key",
  "bankId": "my-copilot-memory"
}

Configuration options

Key Default Description
hindsightApiUrl "" External API URL (empty = local daemon)
hindsightApiToken null API token for Hindsight Cloud
bankId "copilot-cli" Memory bank identifier
bankMission (set) Guides what facts Hindsight retains
autoRecall true Recall memories on sessionStart and subagentStart
autoRetain true Store conversations after each turn
retainMode "full-session" "full-session" or "chunked"
retainEveryNTurns 10 Retain every N turns (1 = every turn)
retainToolCalls true Preserve tool calls/results as structured blocks when retaining
recallFallbackQueryTemplate (set) Query used when there's no specific prompt to recall against (interactive sessionStart with no queued prompt, or any subagentStart). {project} is replaced with the cwd basename
recallBudget "mid" Recall depth: "low", "mid", "high"
recallMaxTokens 1024 Max tokens for injected memories
recallTimeout 10 Timeout in seconds for recall API calls
dynamicBankId false Separate bank per project
dynamicBankGranularity ["agent", "project"] Fields for dynamic bank ID
debug false Log debug info to stderr

Environment variable overrides

All settings can also be set via environment variables:

export HINDSIGHT_API_URL=https://api.hindsight.vectorize.io
export HINDSIGHT_API_TOKEN=your-api-key
export HINDSIGHT_BANK_ID=my-project
export HINDSIGHT_RECALL_TIMEOUT=30
export HINDSIGHT_DEBUG=true

How memory works

Recall — on sessionStart, Hindsight searches your memory bank for facts relevant to the queued prompt (or a generic project-context query when there isn't one) and injects them as additionalContext. The same happens on subagentStart for every subagent spawned during the session, since subagents otherwise run in a fully isolated context with no access to the parent session's memory.

Retain — after configured turns (agentStop) and again when the session ends (sessionEnd), the session transcript is read from Copilot CLI's transcriptPath and stored to Hindsight. The memory engine extracts facts, relationships, and experiences — so you don't need to re-explain your stack, preferences, or past decisions.

Dynamic bank IDs

To keep separate memory per project:

{
  "dynamicBankId": true,
  "dynamicBankGranularity": ["agent", "project"]
}

This creates banks like copilot-cli::my-project automatically, deriving the project name from the cwd field every Copilot CLI hook payload carries.

Troubleshooting

Memory not appearing: enable debug mode ("debug": true) and check that HINDSIGHT_API_URL points to a reachable server. Logs go to ~/.hindsight/copilot-cli/state/*.log when debug is on and stderr is redirected — otherwise check the hook's stderr directly via Copilot CLI's own debug output.

Hooks not firing: check that ~/.copilot/hooks/hindsight-copilot-cli.json (or .github/hooks/hindsight-copilot-cli.json for repo scope) is valid JSON. Copilot CLI loads hook configuration when it starts, so restart the CLI after installing or updating hooks.

Subagents not getting memory: the built-in general-purpose agent never emits subagentStart — this is a Copilot CLI limitation, not a bug in this integration. All other built-in agents (explore, task, code-review, rubber-duck, research, security-review) and custom agents do emit it.

Development

cd hindsight-integrations/copilot-cli
uv sync
uv run pytest tests/ -v

The tests mock the HTTP client, the stdin/stdout pipe, and the file-based state. No live Hindsight server or Copilot CLI installation is required.

License

MIT

Metadata

Release files for hindsight-copilot-cli 0.1.1

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-copilot-cli 0.1.1
File Size Uploaded
hindsight_copilot_cli-0.1.1.tar.gz 40.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hindsight-copilot-cli 0.1.1
File Interpreter ABI Platform
hindsight_copilot_cli-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 80.2 kB

Release files / hindsight_copilot_cli-0.1.1.tar.gz

Download URL hindsight_copilot_cli-0.1.1.tar.gz
Size 40.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9662d9e36190de05d1cd893788e9777b53b66adbee0cefb7d1ebae1a0bad5f19
BLAKE2b-256 checksum
How to use checksums
f896fb29b721d737950dce9799d326642587e920d88d5648376cbcb34a4021d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Jul 30, 2026.

Transparency log

Release files / hindsight_copilot_cli-0.1.1-py3-none-any.whl

Download URL hindsight_copilot_cli-0.1.1-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab8860d2949dff9f0de7a06752e8a260a9861330baf9390673dca24ab9b37ea4
BLAKE2b-256 checksum
How to use checksums
6839de693786fbe126c3f2c2a555730de0e9c8e7a2ad6ba306311c09902ca2dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Jul 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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