Runtime guards for AI agents.
A small TypeScript layer that adds cost caps, token limits, timeouts, and retry controls around existing model or tool calls.
Why
Agent calls can loop, retry, and quietly burn budget. guard-sdk
centralizes runtime limits so teams stop scattering budget checks across every provider
integration.
guard.run()wraps any async call in bounded execution.guard.createRun()tracks multi-step loops with shared limits.- Usage summaries include retries, call count, duration, and cost estimate.
Quickstart
import { createJsonFileLogger, guard } from "@guard-sdk/core";
const { data, usage } = await guard.run(
async () => callLLM(),
{
name: "summarize-report",
maxCostUsd: 1,
maxTokens: 5000,
maxCalls: 3,
maxRetries: 2,
timeoutMs: 30000,
logger: createJsonFileLogger({
filePath: "./.guard/usage.jsonl",
}),
},
); timeoutMs is best-effort: guard rejects on timeout, but the underlying IO must
support cancellation for hard interruption.
Packages
Browse package details in Docs.
API Structure
The API reference pages are generated from each package entry file at build time. Use API Spec to inspect exports grouped by package.