Runtime Guards for AI Agents

apvarun1 pts0 comments

guard-sdk | Runtime Guards For AI Agents Docs<br>Why

Agent calls can loop, retry, and quietly burn budget. guard-sdk<br>centralizes runtime limits so teams stop scattering budget checks across every provider<br>integration.

guard.run() wraps any async call in bounded execution.<br>guard.createRun() tracks multi-step loops with shared limits.<br>Usage summaries include retries, call count, duration, and cost estimate.

Quickstart<br>import { createJsonFileLogger, guard } from "@guard-sdk/core";

const { data, usage } = await guard.run(<br>async () => callLLM(),<br>name: "summarize-report",<br>maxCostUsd: 1,<br>maxTokens: 5000,<br>maxCalls: 3,<br>maxRetries: 2,<br>timeoutMs: 30000,<br>logger: createJsonFileLogger({<br>filePath: "./.guard/usage.jsonl",<br>}),<br>},<br>); timeoutMs is best-effort: guard rejects on timeout, but the underlying IO must<br>support cancellation for hard interruption.

Packages

Browse package details in Docs.

@guard-sdk/anthropic<br>@guard-sdk/cli<br>@guard-sdk/core<br>@guard-sdk/openai<br>@guard-sdk/otel<br>@guard-sdk/pricing<br>@guard-sdk/storage-sqlite<br>@guard-sdk/vercel-ai

API Structure

The API reference pages are generated from each package entry file at build time. Use<br>API Spec to inspect exports grouped by package.

guard runtime usage package guards agents

Related Articles