klock-langchain
klock-langchain is the canonical OSS v1 integration for Klock.
It coordinates LangChain file-mutating tools so multiple agents can work in the same repo without silently overwriting each other.
This is coordination for cooperative tools that call Klock before mutating shared files. It is not yet filesystem-level enforcement.
Install
pip install klock klock-langchain langchain-core
Local workflow
For localhost workflows, use Klock.local(...). It auto-starts the local coordinator on the first lock/register/acquire operation when it can find a launch command.
When auto-start happens, the SDK logs the base URL, launch command, and PID.
Disable auto-start with:
KLOCK_DISABLE_AUTOSTART=1KlockHttpClient(..., auto_start=False)if you use the advanced client directly
Then wrap your tool:
from klock import Klock
from klock_langchain import KlockConflictError, klock_protected
from langchain_core.tools import BaseTool
klock = Klock.local(agent_id="agent-a", session_id="repo-session-a", priority=100)
class WriteFileTool(BaseTool):
name = "write_file"
description = "Mutates a repo file."
@klock_protected(
klock_client=klock,
agent_id="agent-a",
session_id="repo-session-a",
resource_type="FILE",
resource_path_extractor=lambda kwargs: kwargs["path"],
predicate="MUTATES",
)
def _run(self, path: str, content: str) -> str:
with open(path, "w", encoding="utf-8") as handle:
handle.write(content)
return f"updated {path}"
Conflict behavior
klock_protected(...) uses Wait-Die semantics from the Klock server:
GRANT: the tool enters the critical section and runsWAIT: the decorator sleeps for the server-provided backoff and retriesDIE: the decorator raisesKlockConflictErrorso the caller can retry later
Example recovery loop:
try:
tool.invoke({"path": "src/auth.js", "content": "..."})
except KlockConflictError as exc:
if exc.reason == "DIE":
# retry later
...
Proof assets
The repo includes deterministic proof scripts built around the same local-server workflow:
- examples/oss_v1/without_klock.py
- examples/oss_v1/with_klock.py
- examples/oss_v1/wait_die_trace.py
- examples/oss_v1/langchain_base_tool_demo.py
Run them from examples/oss_v1/README.md.
Metadata
Release files for klock-langchain 0.1.3
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 |
|---|---|---|---|---|
| klock_langchain-0.1.3.tar.gz | 10.1 kB | Without provenance | Details for klock_langchain-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| klock_langchain-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for klock_langchain-0.1.3-py3-none-any.whl |
Total release size: 15.1 kB
Release files / klock_langchain-0.1.3.tar.gz
| Download URL | klock_langchain-0.1.3.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28c81f612684d6f102dd26942bca9d1f814a6ec6c6a44d2022c6b88bd3c702e6
|
|
BLAKE2b-256 checksum How to use checksums |
f035b33473bccbaffdacec22ec0a38ac494d14a92431541625778551cc2ab48d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / klock_langchain-0.1.3-py3-none-any.whl
| Download URL | klock_langchain-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65352ea30328f498b1d90814512f9bed5d3f9a6ef7e8b06ff63a48036781c7ac
|
|
BLAKE2b-256 checksum How to use checksums |
b021b01105190a4d261d6213b20ac0f04fcf1aa35de89b88226b0500ae0f26d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for klock-langchain 0.1.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.