CrewAI integration for LatchGate — execution security kernel for AI agents
Project description
latchgate-crewai
CrewAI integration for LatchGate — execution security kernel for AI agents.
Every tool call goes through LatchGate's enforcement pipeline: auth => policy => WASM sandbox => verification => signed receipt. The LLM never holds credentials and never contacts external systems directly.
Installation
pip install latchgate-crewai
Requires a running LatchGate instance:
curl -fsSL https://raw.githubusercontent.com/latchgate-ai/latchgate/main/install.sh | bash && latchgate up
Quick start
from crewai import Agent, Task, Crew
from latchgate_crewai import LatchGateToolset
# Sync factory (preferred for CrewAI's synchronous kickoff):
toolset = LatchGateToolset.create_sync(gate_url="http://localhost:3000")
tools = toolset.all()
agent = Agent(
role="Secure Worker",
goal="Perform tasks through gated tools with full audit trail",
backstory="You are an agent with access to LatchGate-protected actions.",
tools=tools,
)
task = Task(
description="Fetch https://httpbin.org/get and report the response",
expected_output="The HTTP response body",
agent=agent,
)
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()
print(result)
API
LatchGateToolset
Main entry point. Discovers actions and wraps them as CrewAI tools.
# Sync factory (works everywhere, including inside running event loops):
toolset = LatchGateToolset.create_sync(
gate_url="http://localhost:3000", # Required (or set LATCHGATE_URL)
agent_id="my-agent", # Default: "crewai"
include={"http_fetch", "database"}, # Optional: only these actions
exclude={"send_message"}, # Optional: skip these actions
on_audit=my_audit_callback, # Optional: receipt callback
)
# Async factory:
toolset = await LatchGateToolset.create(gate_url="http://localhost:3000")
tools = toolset.all() # list[BaseTool]
tool = toolset.get("http_fetch") # single tool by action_id
ids = toolset.action_ids # list[str]
client = toolset.client # LatchGateClient (for direct access)
Use as an async context manager for automatic cleanup:
async with await LatchGateToolset.create(gate_url="...") as toolset:
tools = toolset.all()
Or create from pre-fetched descriptors (synchronous, no I/O):
toolset = LatchGateToolset.from_descriptors(descriptors, client=client)
LatchGateTool
Individual tool wrapping a single action. Created automatically by LatchGateToolset, but can be used directly:
from latchgate import LatchGateClient
from latchgate_crewai import LatchGateTool, ActionDescriptor
client = LatchGateClient(base_url="http://localhost:3000", agent_id="my-agent")
descriptor = ActionDescriptor(
action_id="http_fetch",
version="1.0.0",
risk_level="low",
request_schema={"type": "object", "properties": {"url": {"type": "string"}}, "required": ["url"]},
description="Fetch a URL through LatchGate",
)
tool = LatchGateTool.from_descriptor(descriptor, client)
discover_actions
Low-level discovery function:
from latchgate_crewai import discover_actions
descriptors = await discover_actions("http://localhost:3000", include={"http_fetch"})
Error handling
LatchGate errors are returned as structured error strings (not exceptions) so the CrewAI agent can reason about them:
| LatchGate error | Tool returns |
|---|---|
| Policy denied | "ERROR: Action '...' denied: {reason}..." |
| Approval required | "ERROR: ... requires human approval..." (approval_id emitted via log, not to the model) |
| Budget exhausted | "ERROR: Budget exhausted..." |
| Transport / infra | "ERROR: LatchGate error..." |
Output format
Tool output is a JSON string containing only the action result. Enforcement metadata (receipt ID, trace ID, verification) is never returned to the model — it is emitted at INFO log level and via the optional on_audit callback.
{"status": 200, "body": "{...}"}
License
Apache-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 latchgate_crewai-0.1.1.tar.gz.
File metadata
- Download URL: latchgate_crewai-0.1.1.tar.gz
- Upload date:
- Size: 296.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8922cabc3f102f66441457a405b5962f41f6071b566fea63e208a229e4aba154
|
|
| MD5 |
21673ceba6c4a1fb5c891d9d5dcc9a79
|
|
| BLAKE2b-256 |
4d443a890df7f835ed055f32a2fe93326418c9fee7c9bb94bc248ca686494100
|
Provenance
The following attestation bundles were made for latchgate_crewai-0.1.1.tar.gz:
Publisher:
release.yml on latchgate-ai/latchgate-integrations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
latchgate_crewai-0.1.1.tar.gz -
Subject digest:
8922cabc3f102f66441457a405b5962f41f6071b566fea63e208a229e4aba154 - Sigstore transparency entry: 1754734021
- Sigstore integration time:
-
Permalink:
latchgate-ai/latchgate-integrations@00b7380c470ac7386569e68d1cf429a1e2354829 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/latchgate-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@00b7380c470ac7386569e68d1cf429a1e2354829 -
Trigger Event:
push
-
Statement type:
File details
Details for the file latchgate_crewai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: latchgate_crewai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e52444578d7c04570c24bfab86d3aced6626e1948fdfb46c4560db31beea55b9
|
|
| MD5 |
f33b86286c1659cf3646f4c8a1ea92ac
|
|
| BLAKE2b-256 |
7fbd52d4e164df97d0f94d519cdb5bb6dd026b4388ceabf5534f9de176486780
|
Provenance
The following attestation bundles were made for latchgate_crewai-0.1.1-py3-none-any.whl:
Publisher:
release.yml on latchgate-ai/latchgate-integrations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
latchgate_crewai-0.1.1-py3-none-any.whl -
Subject digest:
e52444578d7c04570c24bfab86d3aced6626e1948fdfb46c4560db31beea55b9 - Sigstore transparency entry: 1754734025
- Sigstore integration time:
-
Permalink:
latchgate-ai/latchgate-integrations@00b7380c470ac7386569e68d1cf429a1e2354829 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/latchgate-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@00b7380c470ac7386569e68d1cf429a1e2354829 -
Trigger Event:
push
-
Statement type: