Hindsight for ZCode
Long-term memory for ZCode — Z.ai's GLM desktop coding agent. Remembers your projects, preferences, and past sessions across every conversation.
ZCode ships a native process-hook system, so Hindsight plugs in through hooks — no MCP server required. The installer writes to ZCode's CLI config (~/.zcode/cli/config.json), never your real Claude Code config, and enables config hooks (off by default).
How it works
Three ZCode hooks keep memory in sync automatically:
| Hook | Action |
|---|---|
SessionStart |
Confirms Hindsight is reachable and pre-warms the local daemon if needed |
UserPromptSubmit |
Recalls relevant memories (injected via hookSpecificOutput.additionalContext) and stashes the prompt for the next retain |
Stop |
Pairs the stashed prompt with the assistant reply and retains the turn to long-term memory |
ZCode has no SessionEnd event, so retain rides Stop. Each turn is stored as its own memory (distinct document_id).
Requirements
- ZCode with config-hooks support (
~/.zcode/cli/config.json) - 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-zcode
Then run the installer once:
# Hindsight Cloud
hindsight-zcode install --api-url https://api.hindsight.vectorize.io --api-token your-api-key
# Local daemon (hindsight-embed) — omit the flags
hindsight-zcode install
The installer:
- Copies the hook scripts to
~/.zcode/hooks/hindsight/ - Merges Hindsight's hooks into
~/.zcode/cli/config.jsonunderhooks.events(preserving any existing keys and foreign hooks), setshooks.enabledtotrue, and uses absolute paths to the scripts - Seeds
~/.hindsight/zcode.jsonif it doesn't exist (drop yourhindsightApiTokenhere later)
Restart ZCode to load the hooks. If memories are not recalled or retained, check that
~/.zcode/cli/config.json has "hooks": {"enabled": true, ...} with the Hindsight entries and that python3 is on $PATH from your shell.
Uninstall
hindsight-zcode uninstall
This removes the hook scripts and strips Hindsight's entries from ~/.zcode/cli/config.json. Any other keys and foreign hooks in that file, and your personal config at ~/.hindsight/zcode.json, are preserved.
Configuration
Default config lives in ~/.zcode/hooks/hindsight/settings.json. For personal overrides stable across updates, create ~/.hindsight/zcode.json:
{
"hindsightApiUrl": "https://api.hindsight.vectorize.io",
"hindsightApiToken": "your-api-key",
"bankId": "my-zcode-memory"
}
Configuration options
| Key | Default | Description |
|---|---|---|
hindsightApiUrl |
"" |
External API URL (empty = local daemon) |
hindsightApiToken |
null |
API token for Hindsight Cloud |
bankId |
"zcode" |
Memory bank identifier |
bankMission |
(set) | Guides what facts Hindsight retains |
autoRecall |
true |
Inject memories before each prompt |
autoRetain |
true |
Store conversations after each turn |
retainMode |
"full-session" |
"full-session" or "chunked" |
retainEveryNTurns |
10 |
Retain every N turns (1 = every turn) |
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 — before each prompt, Hindsight searches your memory bank for facts relevant to what you're about to ask. Found memories are injected via the Claude Code hookSpecificOutput.additionalContext field so the agent has continuity across sessions.
Retain — after configured turns and again when the session ends, ZCode's conversation transcript is 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 zcode::my-project automatically, using the hook's cwd (set by the Claude Code runtime), the optional ZCODE_PROJECT_DIR env var, or the first entry of workspace_roots.
Troubleshooting
Memory not appearing: enable debug mode ("debug": true, or HINDSIGHT_DEBUG=true) and check that HINDSIGHT_API_URL points to a reachable server.
Hooks not firing: check that ~/.zcode/cli/config.json is valid JSON, that hooks.enabled is true, and that the Hindsight entries are present under hooks.events. ZCode requires a session restart to pick up new hooks.
Development
cd hindsight-integrations/zcode
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 is required.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hindsight_zcode-0.1.0.tar.gz.
File metadata
- Download URL: hindsight_zcode-0.1.0.tar.gz
- Upload date:
- Size: 37.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f45162ba8f4d126f49e60de012f2e61ec3a711bf120af2f5ebc9c8144f4a8057
|
|
| MD5 |
b8f4f2375d6c06384577e2a15b9fff91
|
|
| BLAKE2b-256 |
23b3991a88c60c2bf753897900d5ef6d9050baab97eb3f4acdcb4bf90b399f6e
|
Provenance
The following attestation bundles were made for hindsight_zcode-0.1.0.tar.gz:
Publisher:
release-integration.yml on vectorize-io/hindsight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hindsight_zcode-0.1.0.tar.gz -
Subject digest:
f45162ba8f4d126f49e60de012f2e61ec3a711bf120af2f5ebc9c8144f4a8057 - Sigstore transparency entry: 2206761016
- Sigstore integration time:
-
Permalink:
vectorize-io/hindsight@6e03dd2d4ca803d509a37ead3f4fe4737fdf9fe8 -
Branch / Tag:
refs/tags/integrations/zcode/v0.1.0 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integration.yml@6e03dd2d4ca803d509a37ead3f4fe4737fdf9fe8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hindsight_zcode-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hindsight_zcode-0.1.0-py3-none-any.whl
- Upload date:
- Size: 34.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56625258d0f5dd02b9a9beefaa046c06afb964dd12b8bddfcc7ceb3329caa09d
|
|
| MD5 |
42d51ac034fbc495ab97afaca641e8f1
|
|
| BLAKE2b-256 |
a399d2f002f11715778a587359d97a021b7342c9b6bb3d004d359626bacb3f00
|
Provenance
The following attestation bundles were made for hindsight_zcode-0.1.0-py3-none-any.whl:
Publisher:
release-integration.yml on vectorize-io/hindsight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hindsight_zcode-0.1.0-py3-none-any.whl -
Subject digest:
56625258d0f5dd02b9a9beefaa046c06afb964dd12b8bddfcc7ceb3329caa09d - Sigstore transparency entry: 2206761036
- Sigstore integration time:
-
Permalink:
vectorize-io/hindsight@6e03dd2d4ca803d509a37ead3f4fe4737fdf9fe8 -
Branch / Tag:
refs/tags/integrations/zcode/v0.1.0 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integration.yml@6e03dd2d4ca803d509a37ead3f4fe4737fdf9fe8 -
Trigger Event:
push
-
Statement type: