Director's Commentary middleware for AI agents — captures decision traces, builds dynamic brain maps, and evolves institutional wisdom
Project description
Graphmind Context Graphs — Python SDK
A "Director's Commentary" middleware for LangChain Python agents. Captures why agents make decisions, not just what they did.
Installation
pip install graphmind-context-graphs
Prerequisites
# Graphmind database
docker run -d --name graphmind -p 8080:8080 fabischk/graphmind:latest
# LangChain + provider
pip install langchain langchain-core langgraph langchain-openai
Quick Start
from langchain.agents import create_agent
from graphmind_context_graphs import (
create_context_graph,
ContextGraphConfig,
EmbeddingConfig,
)
# Your embedding provider (must implement embed, embed_batch, dimensions)
embedding_provider = MyEmbeddingProvider()
# Initialize
cg = create_context_graph(ContextGraphConfig(
tenant="my_company",
project="support",
agent="support-agent",
embedding=EmbeddingConfig(provider=embedding_provider, dimensions=1536),
observer_model="openai:gpt-4.1-mini", # Optional: for LLM-powered extraction
))
# Create agent with middleware + brain-mapping tools
agent = create_agent(
"openai:gpt-4.1",
tools=[*my_tools, *cg.tools],
middleware=cg.middleware,
)
# Use — context captured and injected automatically
result = agent.invoke({"messages": [{"role": "user", "content": "My account is locked"}]})
# Evolve knowledge
cg.lifecycle.validate_trace(trace_id, ValidationResult(trace_id=trace_id, success=True))
cg.lifecycle.synthesize_rules()
Features
- Decision Trace Capture — Intent/Constraint/Action/Justification triplets
- Dynamic Brain Mapping — Agents create entities (CodeFile, Contract, etc.) and relationships
- Schema Awareness — Agent-scoped; only domain entities shown
- LLM-Powered Extraction — Observer model extracts domain, concepts, constraints
- Knowledge Lifecycle — Capture → Validate → Synthesize → Prune
- Multi-Agent — Shared, isolated, or selective context sharing
- Vector Search — Semantic similarity via Graphmind SEARCH clause
API Mirror
This SDK mirrors the TypeScript SDK. Both use the same Graphmind database and Cypher queries. Agents running in different languages can share context graphs.
| TypeScript | Python |
|---|---|
createContextGraph() |
create_context_graph() |
cg.middleware |
cg.middleware |
cg.tools |
cg.tools |
cg.lifecycle.validateTrace() |
cg.lifecycle.validate_trace() |
cg.store.getSchemaOverview() |
cg.store.get_schema_overview() |
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
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 graphmind_context_graphs-0.2.0.tar.gz.
File metadata
- Download URL: graphmind_context_graphs-0.2.0.tar.gz
- Upload date:
- Size: 198.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1453dc5a3583a5fc5a29f053489a56cdb4648d25ed11f15568184122b8a05bdd
|
|
| MD5 |
7b5d0d3cd9df1d6ef0951c0f44d62e65
|
|
| BLAKE2b-256 |
5dc35e923028edad21eaf73e5cfe33cdd3a9c8771a2460c553480e1313c06e70
|
Provenance
The following attestation bundles were made for graphmind_context_graphs-0.2.0.tar.gz:
Publisher:
publish-pypi.yml on fab679/graphmind-context-graphs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphmind_context_graphs-0.2.0.tar.gz -
Subject digest:
1453dc5a3583a5fc5a29f053489a56cdb4648d25ed11f15568184122b8a05bdd - Sigstore transparency entry: 1196998606
- Sigstore integration time:
-
Permalink:
fab679/graphmind-context-graphs@7ddad30f3129c151abe103ee6e1f6b131a9d3855 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/fab679
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7ddad30f3129c151abe103ee6e1f6b131a9d3855 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphmind_context_graphs-0.2.0-py3-none-any.whl.
File metadata
- Download URL: graphmind_context_graphs-0.2.0-py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d314db2d9332701a6f129f5a7a8397184d3581c5fb77e07a69e1b61db27b4ad
|
|
| MD5 |
633b834b05577c1d23f1eb37f13b5c7a
|
|
| BLAKE2b-256 |
d15417a7a435841bdbb5a8f33d9b5101add8363e2be4f4aa0cb7a688d93524eb
|
Provenance
The following attestation bundles were made for graphmind_context_graphs-0.2.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on fab679/graphmind-context-graphs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphmind_context_graphs-0.2.0-py3-none-any.whl -
Subject digest:
6d314db2d9332701a6f129f5a7a8397184d3581c5fb77e07a69e1b61db27b4ad - Sigstore transparency entry: 1196998621
- Sigstore integration time:
-
Permalink:
fab679/graphmind-context-graphs@7ddad30f3129c151abe103ee6e1f6b131a9d3855 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/fab679
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7ddad30f3129c151abe103ee6e1f6b131a9d3855 -
Trigger Event:
push
-
Statement type: