Skip to content
  • TypeScript
  • LangGraph
  • Zod
  • SSE
  • OpenTelemetry
  • npm

langgraph-zod

The runtime type system and structural API boundary layer for LangGraphJS agents — deriving production-ready Zod boundary schemas directly from graph state channels.

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): derives inputSchema and outputSchema from state definitions — omitting internal scratchpads and keys before they leak into public API output.
  • Streaming-First SSE Validation: incremental SSE parser + TransformStream validates graph.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.