keelgate.adapters.langgraph¶
Stability of each symbol (stable or provisional) is listed in the API contract. Narrative and semantics are in the integration contract.
LangGraph adapter: governed tools, a chat-model wrapper, and the durable checkpoint store.
keelgate[langgraph] provides the SDK. The loop's default durable checkpointer lives in
keelgate.loop and is re-exported here for convenience.
KeelgateChatModel
¶
Bases: BaseChatModel
A LangChain chat model whose completions come from a Keelgate LLMClient.
LangGraphCheckpointStore
¶
Loop checkpoints on a LangGraph saver.
The stale-writer guard (save refuses a sequence that is not newer) is a read followed by
a write, which LangGraph's saver API cannot make atomic by itself. Two locks make it atomic:
a thread lock for threads of one process, and an optional process_lock for other
processes. :meth:sqlite on a real file supplies one (a separate <path>.lock SQLite file
held under BEGIN IMMEDIATE). With a saver you build yourself (for example Postgres) and no
process_lock, the guard is thread-safe only; pass a lock that suits your backend, or use
:class:~keelgate.loop._checkpoint.SqliteCheckpointStore.
history
¶
Every checkpoint of a run, oldest first.
governed_langchain_tools
¶
One LangChain tool per governed tool. Each call goes through the gateway.
The coroutine never raises for a refusal: a denial, a parked approval or a validation error comes back as the rendered result text, so the agent can read it and adapt, and the framework's own error handling never sees (or retries) a policy decision.
to_keelgate_messages
¶
Convert LangChain messages into Keelgate Message objects.