ADR-0021: Zod stays a required peer
- Status: Accepted
- Date: 2026-11-21
- Supersedes in part: ADR-0020, point 4 ("
zodbecomes an optional peer"). The rest of ADR-0020 stands.
Context
ADR-0020 planned to make zod an optional peer, on the premise that a site using only the script tag and no tools never needs it.
While implementing ADR-0020 (task 0.5-1), we found the premise wrong:
defineBotvalidates every bot definition with a Zod schema (src/bot/define-bot.ts), and so doesdefineTheme(src/theme/theme.ts).- Every askdare site calls
defineBot, so every site loadszodat startup, with or without tools.
Decision
zodstays a required peer (^4.1), as in ADR-0006.- We don't move it to
dependencies. Tool schemas written by the app must come from the same Zod the library uses forzodResponsesFunction, and a peer dependency is what guarantees that.
Consequences
- Nothing changes for users. The support matrix row for Zod stays as in ADR-0006.
- Making Zod optional would need validation that doesn't depend on Zod (hand-written checks, or a schema-agnostic tool API such as Standard Schema). ADR-0020 already lists that as worth looking at before 1.0.
Alternatives considered
- Lazy-load Zod only for tools:
defineBotwould still need it for validation. - Hand-written validation in
defineBot: possible, but it duplicates the schema the error messages and docs are built on, for a saving of one peer dependency that every Node.js app with a chatbot can afford.