langgraph-zod — the boundary layer for language agents
TypeScript gives you compile-time safety; LLMs operate in the untyped world of unstructured text. langgraph-zod bridges that gap by deriving production-ready runtime boundary schemas directly from your LangGraph state channel definitions.
Feature highlights
- Boundary Validation (
createGraphSchemas): derivesinputSchemaandoutputSchemafrom state definitions — omitting internal scratchpads and keys before they leak into public API output. - Streaming-First SSE Validation: incremental SSE parser +
TransformStreamvalidatesgraph.streamEvents()payloads on the fly, drops malformed chunks, and handles backpressure — at <1ms per-chunk latency. - Framework-agnostic
AgentBoundary: wraps any async function or async generator — LangGraph, Vercel AI SDK, AutoGen TS, or plain custom agents. - Zod-native channel reducers (
zodChannel) and self-healing LLM output parsing (safeParseLLMOutput) with repair retries. - Production telemetry: OpenTelemetry spans, counters (
validation.error_count,channel.failed_key), and latency histograms. - CLI: export OpenAPI 3.1 specs and diff schemas for breaking changes in CI.
All of it in a 36 KB bundle, with adapters for Next.js, Hono, and Express.