AWS Bedrock Agents
pip install clausgap-bedrockPrivate beta. The SDK packages aren't on the public registries yet. Access comes with onboarding — email hello@clausgap.dev.
Wraps a Bedrock Agent action-group Lambda. Before your action handler runs, the request is evaluated against policy; a denied action returns a Bedrock-native error response instead of executing.
# lambda_handler.py
from clausgap_bedrock import ClausgapBedrockHandler
gate = ClausgapBedrockHandler(
control_url="https://api.clausgap.dev",
api_key=os.environ["CLAUSGAP_API_KEY"],
agent_role="bedrock_support_agent",
)
def handler(event, context):
return gate.handle(event, context, execute_action=my_action)
def my_action(action_group, api_path, parameters):
if api_path == "/lookup_customer":
return lookup_customer(parameters["customer_id"])Using RETURN_CONTROL mode instead of a Lambda action group? Call validate_bedrock_action directly and branch on the decision:
from clausgap_bedrock import validate_bedrock_action
decision = validate_bedrock_action(
control_url="https://api.clausgap.dev",
api_key=os.environ["CLAUSGAP_API_KEY"],
agent_role="bedrock_agent",
action_group="support_actions",
api_path="/refund_order",
)
# decision: "allow" | "deny" | "escrow" | "rate_limited"Escrow holds
A policy's escrow rule works the same way here as everywhere else — see the escrow flow →. In RETURN_CONTROL mode, an "escrow" decision means you hold the action yourself and poll GET /v1/escrow/{id} before proceeding.
Use the agent's own key
Give the integration the agent's own key — registered with POST /v1/keyless/api-keys, the same key the proxy accepts — and set CLAUSGAP_TENANT_ID to your tenant ID. The key then fixes the agent's role and ID (the configured role must match it) and can only evaluate tool calls: it can't change policies or issue keys. A tenant API key also works, but lets the agent name any role, and Discovery Mode only lets calls through for agent keys. Set CLAUSGAP_ENVIRONMENT and CLAUSGAP_SCOPES to match your proxy's, if you use them. See agent keys →