vinc-langgraph
Vinc for LangGraph and LangChain agents. Vinc is a knowledge graph you share with AI: the decisions, records and documents your team wrote, with the reasons attached. This package brings the relevant part of it into your graph nodes and model calls.
Install
pip install vinc-langgraph # node helpers and tools
pip install "vinc-langgraph[agents]" # plus the middleware for create_agent
Set VINC_API_KEY to a member key. A vinc_ro_ key is enough for everything except record_episode.
In a graph node
from vinc_client import VincClient
from vinc_langgraph import build_system_message, get_vinc_context
vinc = VincClient()
def review(state):
block = get_vinc_context(vinc, state["messages"]) # newest human message
system = build_system_message(block, "You review design changes.")
return {"messages": [llm.invoke([system, *state["messages"]])]}
get_vinc_context makes one call, two when nothing matched or several nodes tied (it then widens with a search). It returns None when nothing matched, and also when Vinc is unreachable or the daily limit is spent, so the node goes on without it. A wrong key or space raises.
Ordinary VincContextMiddleware lookups cache for 60 seconds by default, isolated
by client, reader, endpoint, space and rendering settings. Call clear_cache()
after a source update, or set cache_seconds=0 for a fresh read at each model
call. This does not bypass the server's entitlement caches.
In a create_agent agent
from langchain.agents import create_agent
from vinc_langgraph import VincContextMiddleware
agent = create_agent("openai:gpt-5", middleware=[VincContextMiddleware()])
The middleware adds the block to the system message of each model call. An agent that uses tools calls the model several times per question, so the answer is kept for 60 seconds (cache_seconds) instead of spending a Vinc call each time.
Tools the model can call
from vinc_langgraph import create_vinc_tools
tools = create_vinc_tools(VincClient()) # vinc_brief and vinc_search, read only
Inside a create_agent that has VincContextMiddleware, the model may call these two tools at most 4 times per run (tool_calls_per_run; a run is everything after the newest human message). The fifth call gets a sentence saying the cap is reached instead of a Vinc call. The count comes from the graph state, so concurrent runs on one agent do not share it. A graph that uses the tools without the middleware is not capped. vinc-agent-framework applies the same cap and sentence.
Recording, after a person approved
Nothing in this package writes on its own. Put record_episode in the node after an interrupt(), and give only that node a vinc_sk_ key. examples/approve_then_record.py is a complete graph:
context -> review -> approve (interrupt) -> record
The example accepts a host-provided checkpointer for durable recovery; its
default InMemorySaver lasts only for that process. Persist the episode id and
date before approval, and pass the same episode_id to record_episode on a
retry. This merges the same Episode; it does not make other side effects run
exactly once.
Structured review with one parse retry
from vinc_langgraph import run_review, arun_review, UnparsedReview
try:
review = run_review(model, "Review this draft against its cited rules")
except UnparsedReview:
# Stop the revision path and escalate to a person.
raise
Use these helpers inside a review node. They invoke a standalone model with
with_structured_output(ReviewOutput, include_raw=True); no tool executor or
graph writer runs. arun_review provides the same async behavior. For a provider
without structured output support, select native_structured=False explicitly.
The helper retries one malformed output with sanitized feedback and then raises
UNPARSED, preserving the difference between an unparsed review and no findings.
Service and unsupported-schema errors propagate; config is passed unchanged.
Pass provider generation parameters through options, for example
options={"max_completion_tokens": 2048, "reasoning_effort": "low"}. They are
forwarded unchanged on both attempts, without adding max_tokens or
temperature. The helper owns tools, tool_choice and response_format;
these keys cannot override its structured review schema.
Parsed citations still need permission/existence checks, and person-only
requests still require approval before any action.
Receive a handoff package
For an id held in graph state, use a node helper:
from vinc_langgraph import get_vinc_package_context, build_system_message
def receive(state):
block = get_vinc_package_context(reader, state["package_id"], space=state["space"])
return {"messages": [llm.invoke([
build_system_message(block, "Review the prior conclusion and cite available evidence."),
*state["messages"],
])]}
aget_vinc_package_context is the async twin. For an agent bound to one handoff,
the agents extra also provides middleware:
from vinc_langgraph import PackageProvider
receiver = create_agent(model, middleware=[PackageProvider(
"record:dashboard-handoff", space="personal", client=reader,
)])
This is a same-space Record read under the recipient's current key. Unlike the
question lookup middleware, packages and permission checks are never cached.
Every model call rereads the package and distinct evidence ids. Missing carriers
fail explicitly; unavailable evidence is marked uncitable. Nothing writes on
read or completion. Write the producer's package with client.write_package
explicitly, and put record_episode in the approved write-back node as before.
Prefetch the selected role's evidence
middleware = VincContextMiddleware(
client=reader, prefetch_role="concept:agent-reviewer-judgement",
prefetch_max_chars=120000,
)
This reads the complete role contract, full required documents with verified
content hashes, and task brief/search before
each model call, including the returned node ids. Unlike ordinary question
lookup, the role prefetch mode does not cache content or permission checks.
Read tools may still be passed to create_agent as an additional lookup path.
Missing, partial or unverified required documents raise prefetch_spec_unresolved
and no optional task lookup result is used. Authentication/service failures raise; nothing
writes or delegates work.
Graph nodes can call prefetch(reader, role_id, task) or async aprefetch and
pass its returned block to build_system_message. The chosen role comes from
application/operator configuration. prefetch_max_chars controls the combined
middleware budget (default 24,000 characters). Large roles need an explicit
larger budget, as above. Exceeding it raises prefetch_budget_exceeded instead of
truncating the contract or required documents. The helpers use max_chars for
the same budget. With client 0.1.3 or later, the propagated exception's
message and details["required_size"] give the complete required context size.
Set prefetch_max_chars=error.details["recommended_max_chars"] after accepting
that input cost to leave up to 6,000 characters for task evidence too. The client
reads all required documents before reporting budget overflow and discards optional
task lookup results on that failure; it never raises the limit or retries automatically.
The size can change when graph content changes. All 23 hosted roles exceeded the
default in the 2026-10-06 measurement; successful blocks were 34,640 to 217,070
characters (characters are not tokens). With client 0.1.3, required reads
run in bounded concurrent batches. With client 0.1.4, task brief/search may start
before validation and are discarded if the integrity or budget checks fail. A failed batch stops further batches;
already launched reads are cancelled when possible and drained before return.
No prefetch cache or automatic reuse is added. To keep sequential reads, pass a
reader created with prefetch_concurrency=1; the client default is 8.
Model citation quality must be evaluated separately.
License
MIT
Final output gate
from vinc_client import OutputGate
from vinc_langgraph import create_output_gate_middleware, evaluate_output_node
gate = OutputGate(fresh_role["props"])
middleware = create_output_gate_middleware(gate, evidence=host_evidence_for_this_run)
# Pass middleware=[middleware] to create_agent; use invoke()/ainvoke().
Intermediate AI tool-call messages continue to the tool loop. The final response
is checked outside the model; block and interrupt raise OutputGateStopped.
This does not authorize or undo tool execution. Do not expose unchecked model
stream events to an end user.
For an explicit StateGraph, place evaluate_output_node(state, gate, evidence=host_evidence) after the model node, declare vinc_output_gate in the
state schema and route its verdict to delivery, stopping, or a separate approval
node. The helper returns decisions and bounded evidence, not the original answer.
require_output_pass is available when the graph should raise instead of routing.
State-provided proof dictionaries are ignored. Neither path calls another model
or automatically stores an episode.
Approval after the model
Have the model node store a vinc_client.RoleOutput dictionary in role_output.
Declare vinc_approval in your StateGraph state schema and add a separate node:
from vinc_langgraph import create_person_only_node
approval = create_person_only_node(gate, role_id=fresh_role["id"], run_id=run_id)
graph.add_node("approval", approval)
graph.add_edge("model", "approval")
Compile with a checkpointer and use the same thread ID when resuming. The node
emits a draft-bound native interrupt when a structured request or gate identifies
a person-only action. An authenticated human response resumes with
Command(resume={"request_id": pending["request_id"], "approved": True}).
The completed model node is not repeated. Deliver only the checked
vinc_approval result; rejected output has no deliverable. Blocking checks cannot
be overridden by approval. Keep side-effect tools separately authorized.
Use a durable checkpointer in production and never expose unchecked model stream events. This follows the framework's interrupt contract.
Metadata
Release files for vinc-langgraph 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vinc_langgraph-0.1.4.tar.gz | 26.4 kB | With provenance | Details for vinc_langgraph-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vinc_langgraph-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for vinc_langgraph-0.1.4-py3-none-any.whl |
Total release size: 43.6 kB
Release files / vinc_langgraph-0.1.4.tar.gz
| Download URL | vinc_langgraph-0.1.4.tar.gz |
|---|---|
| Size | 26.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea2946b88dc6b7e2ef38b253366f2e32df353fe74499f8f45cde2b757e6fb021
|
|
BLAKE2b-256 checksum How to use checksums |
27e01d86f93a0a3ec764ca9f95b046d9fc4fd9b0f86500da0652124cc53723ef
|
| 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 Oct 13, 2026.
Transparency logRelease files / vinc_langgraph-0.1.4-py3-none-any.whl
| Download URL | vinc_langgraph-0.1.4-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
febda4cb4d2644f1ce4b40163b3574be0a0c87d77e3307dff8e03d2b90ed9270
|
|
BLAKE2b-256 checksum How to use checksums |
d1e7f664e75c5dea179cb38e2ce76b56be0360dae6273feb45fb4298b247a81a
|
| 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 Oct 13, 2026.
Transparency logSecurity for vinc-langgraph 0.1.4
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.
Attestation for vinc_langgraph-0.1.4.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 Oct 13, 2026.
Transparency logA 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.