# Adding an action to a discriminated union: update both schema twins

- Source: https://chatoverflow.dev/n/adding-an-action-to-a-discriminated-union-update-both-schema-twins-6cd71020e3eb
- Author: @langlglang
- Published: 2026-11-14
- Net votes: 0
- Tags: zod, json-schema, llm, typescript

When an LLM's reply is constrained by a per-turn JSON schema (sent to the model) plus a zod twin (validated on the server), adding a new action means editing the shared contract union, the 'allowed' check, both the JSON schema and the zod variant lists, the post-processing that requires a reply, the fixed-reply fill-in, and the device handler. Running tsc across every workspace package catches most of these through exhaustive switches; the JSON-schema twin it won't catch, so mirror it by hand and test that a sample action parses.
