agentwall
Safety middleware for AI agent tool calls, available for Python and TypeScript.
Agents routinely execute shell commands, write files, mutate databases, and call authenticated APIs. Most tool-use stacks pass those calls directly to application code. agentwall adds a small interception layer that classifies each call, requests approval when required, emits a structured event, and registers an optional rollback.
from agentwall import Agentwall, BlockedError
wall = Agentwall()
@wall.tool("bash")
def bash(command: str) -> str:
return f"executed: {command}"
try:
bash("rm -rf /tmp/build-cache")
except BlockedError:
print("blocked")
# The destructive call runs only after terminal approval.
Install
Python 3.9+:
pip install agentwall-sdk
Node.js 18+:
npm install agentwall-sdk
The core packages have no runtime dependencies. Framework clients are optional.
Demo
Quickstart
Python
Decorate an existing tool, or execute a ToolSpec inside a rollback-capable session:
from pathlib import Path
from agentwall import Agentwall, ToolSpec
wall = Agentwall() # loads ./agentwall.yaml
def write_file(path: str, content: str) -> str:
Path(path).write_text(content)
return path
def remove_file(path: str, content: str) -> None:
Path(path).unlink(missing_ok=True)
with wall.session(agent_id="worker-1") as session:
session.call(
ToolSpec("write_file", write_file, remove_file),
path="result.txt",
content="done",
)
If the session exits with an exception, successful calls with rollback functions are compensated in reverse order. Normal exit commits the session.
Adapters accept the native OpenAI, Anthropic, and LangChain tool-call shapes:
from agentwall.integrations import (
execute_anthropic_tool_use,
execute_openai_tool_call,
wrap_langchain_tool,
)
result = execute_openai_tool_call(tool_call, tools_by_name, wall)
result = execute_anthropic_tool_use(tool_use, tools_by_name, wall)
guarded_tool = wrap_langchain_tool(langchain_tool, wall)
TypeScript
import { Agentwall } from "agentwall-sdk";
const wall = new Agentwall();
const guarded = wall.wrap("bash", async ({ command }) => {
return runCommand(String(command));
});
await guarded({ command: "rm -rf /tmp/build-cache" });
executeOpenAIToolCall, executeAnthropicToolUse, and wrapLangChainTool are exported from the TypeScript package.
Classification and approval
Each call is classified as:
| Level | Typical actions | Default behavior |
|---|---|---|
safe |
reads, searches, read-only SQL | execute |
cautious |
file writes, unauthenticated mutations | execute and log |
destructive |
destructive SQL or shell commands, authenticated mutations | require approval |
Terminal approval is fail-closed. WebhookApproval posts the tool name, arguments, and classification to an HTTP endpoint and accepts only a successful response containing {"approved": true}.
Configuration
agentwall reads one agentwall.yaml from the working directory. Set AGENTWALL_CONFIG to use another YAML or JSON file.
approval:
levels: ["destructive"]
logging:
sink: file
path: .agentwall/events.jsonl
webhook:
url: null
timeout_seconds: 30
default_classification: safe
redact_keys: ["authorization", "api_key", "token", "password", "secret"]
rules:
- name: destructive-shell
classification: destructive
tool_pattern: "(?i)^(bash|shell|terminal)$"
argument_pattern: "(?i)(rm\\s+-rf|mkfs|shutdown)"
- name: file-writes
classification: cautious
tool_pattern: "(?i)(write|save|patch)_file"
Rules are evaluated in order; the first complete match wins.
| Key | Type | Default | Description |
|---|---|---|---|
approval.levels |
list | ["destructive"] |
Classifications requiring approval |
logging.sink |
file or stdout |
file |
Built-in event destination |
logging.path |
string | .agentwall/events.jsonl |
JSONL path for the file sink |
webhook.url |
string or null |
null |
Synchronous approval endpoint |
webhook.timeout_seconds |
number | 30 |
Approval request timeout |
default_classification |
classification | safe |
Result when no rule or built-in matches |
redact_keys |
list | common credential keys | Keys recursively redacted from logs |
rules[].name |
string | required | Stable rule name |
rules[].classification |
classification | required | Result for a matching rule |
rules[].tool_pattern |
regex | .* |
Tool-name matcher |
rules[].argument_pattern |
regex | unset | Matcher applied to serialized arguments |
rules[].methods |
list | [] |
Optional HTTP method matcher |
Environment overrides:
| Variable | Purpose |
|---|---|
AGENTWALL_CONFIG |
Config file path |
AGENTWALL_APPROVAL_LEVELS |
Comma-separated approval levels |
AGENTWALL_DEFAULT_CLASSIFICATION |
Default classification |
AGENTWALL_LOG_SINK |
file or stdout |
AGENTWALL_LOG_PATH |
JSONL output path |
AGENTWALL_WEBHOOK_URL |
Approval endpoint |
AGENTWALL_WEBHOOK_TIMEOUT_SECONDS |
Approval timeout |
AGENTWALL_REDACT_KEYS |
Comma-separated keys to redact |
The dependency-free YAML reader supports mappings, nested mappings, scalar lists, and lists of mappings. It does not support anchors, tags, or multiline scalars.
Replay
Dry-run approved, successful calls in log order:
agentwall replay .agentwall/events.jsonl
Execution replay requires an explicit ReplayRegistry containing sandbox-safe implementations:
agentwall replay .agentwall/events.jsonl --execute --module sandbox_tools
Development
See CONTRIBUTING.md.
License
Apache-2.0
Metadata
Release files for agentwall-sdk 0.1.0
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 | |
|---|---|---|---|---|
| agentwall_sdk-0.1.0.tar.gz | 16.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentwall_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.2 kB
Release files / agentwall_sdk-0.1.0.tar.gz
| Download URL | agentwall_sdk-0.1.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
561a4fe03a886d7c563a12824f5db1a1c74dce19c30e6e99ad682ee5c1bdc0a6
|
|
BLAKE2b-256 checksum How to use checksums |
48da00e0716cb154bcd74f6742c66b3f4c77e422b79b30999c85658e34e3c216
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / agentwall_sdk-0.1.0-py3-none-any.whl
| Download URL | agentwall_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c38ec2742202eb9e221b16a17ebdcb770d3677d012439030318881741af7592d
|
|
BLAKE2b-256 checksum How to use checksums |
d8b060aafdd7da42b28162c3e3eb2bb08eba12e4602156c0984f4e07e483f499
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for agentwall-sdk 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.