Observed since 20 Oct, 21:35 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
agentbuck
Python SDK for AgentBuck, a real-time trust enforcement layer for AI agents.
AgentBuck: A real-time trust enforcement layer for AI agents.
agentbuck is its Python SDK for validating records with a running AgentBuck engine over gRPC. It accepts Python records or CSV data and returns the engine's status, message, and per-record decisions.
tcp://host:port format.idApp) with access to the operation.python -m pip install agentbuck
See the package on PyPI for available versions.
Set your API key in the process environment. For example:
# macOS / Linux
export AGENTBUCK_API_KEY="your-api-key"
# PowerShell
$env:AGENTBUCK_API_KEY = "your-api-key"
Then validate a batch of records:
import os
from agentbuck import AgentBuckClient
records = [
{"email": "alice@example.com"},
{"email": "bob@example.com"},
]
with AgentBuckClient(
api_key=os.environ["AGENTBUCK_API_KEY"],
endpoint="tcp://your-agentbuck-host:50051",
) as client:
result = client.validate_bulk(
agent_id="your-agent-id",
idApp=123, # Replace with your application ID.
data=records,
)
if result["status"] != "success":
raise RuntimeError(result["message"])
if len(result["decisions"]) != len(records):
raise RuntimeError("Decision count does not match input record count")
for record, decision in zip(records, result["decisions"]):
print(decision, record)
Use the AgentBuckClient context manager to close its gRPC channel when finished. If you do not use a context manager, call client.close().
validate_bulk(agent_id=..., idApp=..., data=...) accepts:
data | Example |
|---|---|
| An iterable of record mappings | [{"email": "a@example.com"}] |
| A single record mapping | {"email": "a@example.com"} |
| A mapping of columns to equal-length lists | {"email": ["a@example.com", "b@example.com"]} |
| A UTF-8 CSV path or open text file | Path("records.csv") |
A DataFrame-like object with to_dict() | A pandas DataFrame (pandas is optional) |
For a CSV file, the first row supplies field names; each following row becomes one record. CSV field values are read as strings. With an open client:
from pathlib import Path
result = client.validate_bulk(
agent_id="your-agent-id",
idApp=123,
data=Path("records.csv"),
)
Record values should be compatible with protobuf Struct (JSON-style values). The SDK loads the input into memory and sends one bulk request; it does not stream records.
validate_bulk returns a dictionary with status, message, and decisions:
{
"status": "success",
"message": "",
"decisions": ["PROCEED", "BLOCK"],
}
Decision values are determined by the AgentBuck engine. On a non-success engine response, the SDK returns the engine's status and message with an empty decisions list. Check status before pairing decisions with input records.
The SDK raises these exceptions for local configuration or gRPC failures:
| Exception | When it occurs |
|---|---|
ConfigurationError | The API key or endpoint configuration is missing or empty. |
AuthenticationError | The engine returns gRPC UNAUTHENTICATED. |
AuthorizationError | The engine returns gRPC PERMISSION_DENIED. |
TransportError | Another gRPC error occurs, or the endpoint scheme is unsupported. |
All four inherit from AgentBuckError. Unsupported input shapes raise TypeError.
Pass an endpoint directly, or provide AGENTBUCK_GRPC_TARGET through an environment file or the process environment:
import os
from agentbuck import AgentBuckClient
client = AgentBuckClient(
api_key=os.environ["AGENTBUCK_API_KEY"],
endpoint="tcp://your-agentbuck-host:50051",
timeout_seconds=30.0,
)
When endpoint is omitted, the SDK resolves the endpoint in this order:
AGENTBUCK_GRPC_TARGET from the file passed as env_file=..., if one was supplied.AGENTBUCK_GRPC_TARGET from the process environment. A .env file in the current working directory is loaded first when present; it does not override an existing process value.For example, a custom environment file can contain:
AGENTBUCK_GRPC_TARGET=tcp://your-agentbuck-host:50051
client = AgentBuckClient(
api_key=os.environ["AGENTBUCK_API_KEY"],
env_file="path/to/agentbuck.env",
)
api_key is always passed explicitly to AgentBuckClient. The SDK does not automatically read AGENTBUCK_API_KEY; that variable is used only by the examples above. The default request timeout is 30 seconds.
import os
from agentbuck import AgentBuckClient
with AgentBuckClient(
api_key=os.environ["AGENTBUCK_API_KEY"],
endpoint="tcp://your-agentbuck-host:50051",
) as client:
health = client.health()
print(health.status, health.message, health.version, health.rules_loaded)
health() returns a HealthResult with status, message, version, and rules_loaded fields.
Keep API keys out of source control and logs. The current SDK uses an unencrypted gRPC channel for tcp:// endpoints, including the API key sent as request metadata. Connect over a trusted private network or a protected tunnel.
Report bugs and request features in GitHub Issues. The SDK is licensed under Apache-2.0; see NOTICE for the copyright notice.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
grpcioEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | grpcio<2.0.0,>=1.71.2 | runtime |
protobufEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | protobuf<6.0.0,>=5.29.0 | runtime |
python-dotenvEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | python-dotenv<2.0.0,>=1.0.0 | runtime |
grpcio-toolsEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | grpcio-tools==1.71.2; extra == "dev" | runtime |
bdist_wheel · 16.52 KB · Python py3
sdist · 16.89 KB · Python source
Shared repository data · GitHub
Observed since 20 Oct, 21:35 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:e945af934e80246e5358a539d455da0cd238644cdfd0e25dad2fc79cad2c40ec