Skip to content

client.guardrails

View as Markdown

client.guardrails — the guardrails operations.

On AsyncKindgi every method is the same, awaited.

list(
*,
limit: int | None = None,
cursor: str | None = None,
name: str | None = None,
scope_kind: Literal['tenant', 'org', 'project'] | None = None,
scope_id: str | UUID | None = None,
inherit: bool | None = None,
timeout: float | None = None,
) -> GuardrailCollectionPage
Signature

List guardrails. GET /v1/guardrails

Cursor-paginated list of registered guardrails. Optional ?name= filters by prefix on guardrail id.

register(
body: RegisterGuardrailBody | Mapping[str, Any] | None = None,
/,
*,
idempotency_key: str | None = None,
timeout: float | None = None,
**fields: Any,
) -> RegisterGuardrailResult
Signature

Register an guardrail. POST /v1/guardrails

Body is a full Guardrail shape. Server validates via @kindgi/guardrails.validateGuardrailSpec. The check id must reference an implementation already available to the runtime; check code is not uploaded through this route.

get(guardrail_id: str | UUID, /, *, timeout: float | None = None) -> Guardrail
Signature

Fetch an guardrail. GET /v1/guardrails/{guardrailId}

outcomes(
guardrail_id: str | UUID,
/,
*,
project_id: str | UUID,
from_: str,
to: str,
recent: int | None = None,
timeout: float | None = None,
) -> GuardrailOutcomes
Signature

What a guardrail's checks came to in a project. GET /v1/guardrails/{guardrailId}/outcomes

Counts from the server, over a window: how many of the guardrail's checks on agent turns in the project passed, were violated (the answer went through: log-only, noop, or an action handed back), blocked (a halt failed the turn) or errored (the check couldn't run; a halt guardrail's error fails the turn too, and is counted here). The same counts per agent version, and the window's latest blocked turns, by run id and time only: a blocked answer stays behind its run's page. A guardrail whose scope didn't match a turn wasn't checked on it. Replays and dry runs aren't counted. Outcomes go with their run's retention, so a window can hold fewer than asked; recordedSince says how far back they go. A guardrail no longer registered still has its outcomes. Needs read on the guardrail and on the project.

unregister(
guardrail_id: str | UUID,
/,
*,
idempotency_key: str | None = None,
timeout: float | None = None,
) -> UnregisterGuardrailResult
Signature

Unregister an guardrail. POST /v1/guardrails/{guardrailId}/unregister