Skip to main content

Latch

Latch checks AI tool calls before they run. It sits between the model and your app's functions, and the model only gets to name a tool and give arguments. Your app decides who the user is, and Latch decides whether that user may make this exact call right now.

Latch is part of Boundary Lab. It is a separate package from Redline and does not share any code with it. Redline grades answers after they are written. Latch blocks calls before they happen.

What it checks

  • The arguments match the tool, with no extra fields.

  • The user holds the permission the tool needs.

  • The recipient is on the allowed list, if the tool has one.

  • Your own access hook says this user may touch this record.

  • The run has not used up its call limit or its time.

  • Big actions wait for another user to approve them. The approval is tied to the exact request, expires, and works once.

  • The same operation id never dispatches twice, even after a restart.

Every decision comes back with a reason code and one plain sentence.

Install

The core needs only pydantic.

pip install boundary-latch

Two extras are optional.

pip install "boundary-latch[demo]"    # the browser demo (fastapi, uvicorn)
pip install "boundary-latch[live]"    # the live model adapter (httpx)

To work on Latch itself, from this folder:

python3 -m venv .venv
.venv/bin/pip install -e ".[dev,demo,live]"
.venv/bin/pytest -q

Try the demo

boundary-latch demo

Nine scenarios play out one at a time. Each step shows who asked for what, the reason code, and what changed in a fake backend for Northwind, a made-up company. The people are labeled sample identities. Sam and Priya are customer agents, and Jordan is a supervisor.

For the same scenarios in a browser:

boundary-latch serve

Open http://127.0.0.1:8765. You can run each scenario from a button, act as a sample identity, propose a refund over $50, switch to Jordan, approve it, and watch the balance move once. The server only listens on 127.0.0.1. To see the codes without any interface, run boundary-latch scenarios, or add --json for machine output.

Check a policy file with boundary-latch check policy.toml. Copy a starter project with boundary-latch init my-app.

Use it in your app

This is the shape of the starter project. The full file is src/boundary_latch/starter/app.py.

from boundary_latch import Decision, Latch, SQLiteStore, ToolSpec, UserContext, load_policy

latch = Latch(load_policy("policy.toml"), SQLiteStore("app.sqlite"))
latch.register(ToolSpec(name="create_ticket", version="1", args_model=TicketArgs,
                        handler=create_ticket))
ctx = UserContext(user_id=user.id, org_id=user.org, permissions=frozenset(user.perms),
                  run_id=conversation_id)
prepared = latch.prepare(ctx, "create_ticket", model_args, operation_id=action_id)
if not isinstance(prepared, Decision):
    result = latch.execute(prepared, ctx)

prepare returns a Decision when the call is blocked. Otherwise it returns a PreparedAction, and needs_approval tells you whether to wait for a supervisor first.

What Latch does not do

  • It does not log anyone in. Your app owns identity.

  • It has no policy server. The policy is one TOML file.

  • It is not a sandbox. A handler runs with your app's own rights.

  • It does not detect prompt injection. It limits what an injected call can do.

  • It cannot make a remote action happen exactly once. It records the attempt and refuses to retry an uncertain one.

  • It does not purge reservations or offer a retry command.

  • It does not stream model responses.

  • It supports one host. It is not tested across several processes.

Docs

  • Integration: replace the sample login, database and tools.

  • Policy: every key in the TOML file.

  • Approvals: what an approval is tied to and how it ends.

  • Limits: run limits, deadlines and uncertain outcomes.

  • Live model: point the demo at a real model.

  • Release: how a version gets published.

Latch is licensed under AGPL-3.0-only. See LICENSE.

Metadata

Release files for boundary-latch 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boundary-latch 0.1.0
File Size Uploaded Provenance Actions
boundary_latch-0.1.0.tar.gz 69.7 kB Without provenance Details for boundary_latch-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for boundary-latch 0.1.0
File Interpreter ABI Platform Actions
boundary_latch-0.1.0-py3-none-any.whl Python 3 none any Details for boundary_latch-0.1.0-py3-none-any.whl

Total release size: 123.0 kB

Release files / boundary_latch-0.1.0.tar.gz

Download URL boundary_latch-0.1.0.tar.gz
Size 69.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4f7746f7175011c4fea62fe896969421555b607219e47ac89c52099e30a33379
BLAKE2b-256 checksum
How to use checksums
0d0cd2f9d4081c7feb93c286a47dd0fd6a422195f50be081ef3e3596244070cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / boundary_latch-0.1.0-py3-none-any.whl

Download URL boundary_latch-0.1.0-py3-none-any.whl
Size 53.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db45d3c078eca29cf2f7439d890fc924006dff45b0b2a60fd0720c1b5ac82468
BLAKE2b-256 checksum
How to use checksums
e0fda65c27e87b9303c4cddb74ebfbb71fa79bd25fb7160408614579fd9a703c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for boundary-latch 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page