DOCUMENTATION & SDK

Integrate guarded execution in fifteen lines of code.

Wrap existing LLM tool calls with the Benchworkslab SDK, attach a versioned policy file, and run in shadow mode before flipping production writes.

SDK Quickstart

Install the client library and route any proposed agent tool call through benchworkslab.verifyAndExecute(). Out-of-bounds payloads pause cleanly at your approval channel instead of hitting downstream APIs.

import { Benchworkslab } from "@benchworkslab/sdk";

const bw = new Benchworkslab({ apiKey: process.env.BENCHWORKSLAB_API_KEY });

const trace = await bw.workflows.execute({
  workflow: "enterprise_tenant_provision",
  mode: "shadow", // flip to "enforce" after validation
  idempotencyKey: `deal_${deal.id}`,
  tenantId: deal.accountId,
  proposedAction: agentToolCall,
});

if (trace.decision === "ESCALATED") {
  await notifyApprover(trace.escalationChannel, trace.signedTraceUrl);
}
from benchworkslab import Benchworkslab

bw = Benchworkslab(api_key=os.environ["BENCHWORKSLAB_API_KEY"])

trace = bw.workflows.execute(
    workflow="enterprise_tenant_provision",
    mode="shadow",
    idempotency_key=f"deal_{deal.id}",
    tenant_id=deal.account_id,
    proposed_action=agent_tool_call,
)

if trace.decision == "ESCALATED":
    notify_approver(trace.escalation_channel, trace.signed_trace_url)

Declarative Policy YAML

Version policy gates alongside your application repository. Rules execute deterministically in under 40ms with zero model inference in the approval path.

workflow: quote_to_cash_amendment
version: 3
pii_filter: strict
rules:
  - name: floor_margin_guard
    condition: "action.unit_price_usd >= 34.00"
    on_fail: escalate
    channel: "#deal-desk-approvals"
  - name: credit_memo_cap
    condition: "action.credit_amount_usd <= 10000"
    on_fail: escalate
    channel: "#finance-controller"
  - name: allowed_regions
    condition: "action.region in ['us-east-1', 'eu-central-1']"
    on_fail: block

Signed Webhook Events

Every decision emits an HMAC-SHA256 signed webhook payload so your backend or SIEM can subscribe to real-time policy verdicts.

Event Type Trigger Condition Payload Guarantee
trace.verified All schema and deterministic rules passed Includes policy digest and downstream idempotency key
trace.escalated Threshold rule paused for human sign-off Includes diff preview and one-time approval token
trace.blocked Hard invariant or PII boundary violated Zero downstream API mutation; full diagnostic trace

Shadow Mode Replay

Use the Benchworkslab CLI to replay historical JSONL traces against proposed policy edits or a new LLM checkpoint before promoting to production.

npx @benchworkslab/cli replay \
  --workflow quote_to_cash_amendment \
  --policy ./policies/policy_v3.yaml \
  --dataset ./fixtures/q3_deals.jsonl \
  --fail-on-regression