agent-handrail
Handrails for production LLM agents: one tool loop and structured-output API across Claude, OpenAI, Gemini and OpenRouter, with the parts that break in real use handled for you.
- Fallback chains across Claude, OpenAI, Gemini and OpenRouter
- Tools defined once in zod, validated both ways
- Structured output with automatic repair
- Human approval gates for risky actions
- Typed run events for traces and logs
- A scripted fake model for offline tests
npm install agent-handrail zodimport { createLLM, generateObject } from "agent-handrail";
import { z } from "zod";
// Claude first; Gemini if it's rate-limited or down.
const llm = createLLM([
"anthropic:claude-opus-5-5",
"gemini:gemini-3.5-flash-lite",
]);
const address = await generateObject({
llm,
name: "address",
schema: z.object({
house: z.string().nullable(),
city: z.string(),
}),
system: "Split the shipping address into parts.",
prompt: "House 12, Street 4, Gulberg III, Lahore",
});





