Guardian Mode
Guardian Mode enables pre-execution policy enforcement. The SDK checks with Kaplaix before a dangerous tool runs. If a policy says “requires review”, the agent waits for a human decision.
How it works
- The SDK calls
POST /v1/policies/checkbefore executing a tool - The API evaluates the action against the active policy
- Based on the verdict and the configured mode, the SDK either proceeds, blocks, or waits for approval
Enforcement modes
| Mode | ALLOW verdict | DENY verdict | REQUIRE_APPROVAL verdict |
|---|---|---|---|
log_only | Proceed | Warn + proceed | Warn + proceed |
block | Proceed | Throw error | Throw error |
require_approval | Proceed | Throw error | Create pending action, poll until decided |
Circuit breaker
Guardian Mode includes a circuit breaker to protect against cascading failures. After 3 consecutive check failures, the circuit opens. By default the SDK fails open (allows the action) — set failOnCircuitOpen: true to fail closed.
SDK usage
import { KaplaixClient } from "@kaplaix/sdk-ts";
const client = new KaplaixClient({
apiKey: "al_live_...",
guardian: {
mode: "require_approval",
approvalTimeoutMs: 120_000, // 2 minutes (default)
pollIntervalMs: 3_000, // 3 seconds (default)
failOnCircuitOpen: false, // fail-open (default)
},
});
const session = client.session({ agentId: "my-agent" });
// checkThen* methods check policy before logging
await session.checkThenLogToolCall({
toolName: "database_query",
argumentsHash: "sha256-hex",
responseStatus: 200,
});API endpoints
POST
/v1/policies/checkCheck an action against the active policy before execution.
Request body:
| Field | Type | Description |
|---|---|---|
toolType | string | Tool classification |
operation | string | Operation type |
targetSystem | string | Target system identifier |
initiatorType | string | Who initiated the action |
GET
/v1/guardian/pending-actionsList pending actions awaiting human decision.
Query parameters:
| Param | Type | Description |
|---|---|---|
status | string | Filter by status: pending, approved, rejected, expired |
POST
/v1/guardian/pending-actions/:id/decideApprove or reject a pending action.
Request body:
{
"decision": "approved"
}Accepted values: approved, rejected.
Last updated on