{"article":{"slug":"typellm-generate-only-when-it-applies","title":"TypeLLM: Generate only when it applies","subtitle":null,"summary":"In Jev, every field is generated on its own. Its documentation puts it plainly: \"every question is evaluated in parallel and in isolation against the same state.\"","content_type":"blog_post","language":"en","canonical_url":"https://typellm.ai/blog/conditional-fields","author":{"name":"TypeLLM","url":null,"person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"TypeLLM","url":"https://typellm.ai/","listing_slug":null,"listing":null},"topics":[{"name":"AI","slug":"ai","url":"https://listedarticles.com/topics/ai"},{"name":"Developer Tools","slug":"developer-tools","url":"https://listedarticles.com/topics/developer-tools"},{"name":"APIs","slug":"apis","url":"https://listedarticles.com/topics/apis"},{"name":"Software Engineering","slug":"software-engineering","url":"https://listedarticles.com/topics/software-engineering"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":497,"reading_minutes":2,"published_at":"2026-10-03T00:00:00.000Z","added_at":"2026-10-03T15:10:39.841Z","updated_at":"2026-10-03T15:10:39.841Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":false},"profile_url":"https://listedarticles.com/articles/typellm-generate-only-when-it-applies","markdown_url":"https://listedarticles.com/articles/typellm-generate-only-when-it-applies.md","example":false,"citation":"TypeLLM, TypeLLM. \"TypeLLM: Generate only when it applies.\" 3 Oct 2026. https://typellm.ai/blog/conditional-fields (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://typellm.ai/blog/conditional-fields"},"body_markdown":"# Generate only when it applies\n\nIn Jev, every field is generated on its own. Its documentation puts it plainly: \"every question is evaluated in parallel and in isolation against the same state.\"\n\nOur last post went one step further: with\n\n```\ndepends_on\n```\n\n, a later field sees the answers of earlier ones. But every field still ran. An earlier answer could change what a field said, never whether it was asked.\n\nNow it can. With\n\n```\nwhen\n```\n\n, earlier answers decide which fields TypeLLM generates next, all in one API call.\n\n## Sort an email, then ask what that kind needs\n\nAn inbox gets invoices, meeting requests and job applications. Each needs something different: an amount, a date, a role. Ask one question first, what kind of email this is, and let its answer decide which follow-up runs:\n\nFor an invoice (\"Amount due: $1,240.00 by October 15\"), the API returns:\n\nA meeting request takes the meeting branch instead and returns\n\n```\n\"meeting_date\": \"2026-10-14\"\n```\n\n; a job application returns its\n\n```\nrole\n```\n\n. Each follow-up is a typed field of its own: a number, a string, an enum.\n\n## Why not just ask everything?\n\nTyped outputs always return a value in the field's type, even when the question makes no sense. Asked of the same invoice without\n\n```\nwhen\n```\n\n, the follow-ups for a meeting date and a job role came back as the string\n\n```\n\"null\"\n```\n\nand\n\n```\n\"engineering\"\n```\n\n: well-typed, and meaningless. With\n\n```\nwhen\n```\n\n, those fields are skipped instead: they have no key in the result, and\n\n```\nresponse.skipped\n```\n\nlists them.\n\n## What a condition can test\n\n```\nwhen\n```\n\nmaps earlier fields to a test of their answers:\n\n* No\n\n  ```\n  depends_on\n  ```\n\n  needed. The fields a condition names become dependencies, so the field also sees their answers.\n* Skips carry on. A field that depends on a skipped field is skipped too: its input does not exist.\n* Mistakes fail early. A misspelt option, a comparison on a text field or an unknown field is an error before anything runs.\n\n## Why one call, not your own code?\n\nYou could do this yourself: call once to classify, read the answer, then call again with the right follow-up. Doing it in one call is better in four ways.\n\n* The email is read once. Every step continues from the same cached prefix, so the email is processed once, not once per call.\n* It is billed once. The TypeLLM API bills what you send in a call, counting the context once. Two calls send, and pay for, the email twice.\n* No glue code. No parsing the first answer, no\n\n  ```\n  if\n  ```\n\n  , no second request to build. The branch lives in the schema, and the answers come back together, with\n\n  ```\n  skipped\n  ```\n\n  saying what did not apply.\n* No round trip in the middle. The condition is checked between steps on the server, so your code never waits on a first answer just to send a second request.\n\n## Try it\n\n```\nwhen\n```\n\nis in TypeLLM 0.5.1 and the TypeLLM API. Run the email example in the playground or read the conditional fields docs.","body_html":"<h1 id=\"generate-only-when-it-applies\">Generate only when it applies</h1>\n<p>In Jev, every field is generated on its own. Its documentation puts it plainly: &quot;every question is evaluated in parallel and in isolation against the same state.&quot;</p>\n<p>Our last post went one step further: with</p>\n<pre><code>depends_on</code></pre>\n<p>, a later field sees the answers of earlier ones. But every field still ran. An earlier answer could change what a field said, never whether it was asked.</p>\n<p>Now it can. With</p>\n<pre><code>when</code></pre>\n<p>, earlier answers decide which fields TypeLLM generates next, all in one API call.</p>\n<h2 id=\"sort-an-email-then-ask-what-that-kind-needs\">Sort an email, then ask what that kind needs</h2>\n<p>An inbox gets invoices, meeting requests and job applications. Each needs something different: an amount, a date, a role. Ask one question first, what kind of email this is, and let its answer decide which follow-up runs:</p>\n<p>For an invoice (&quot;Amount due: $1,240.00 by October 15&quot;), the API returns:</p>\n<p>A meeting request takes the meeting branch instead and returns</p>\n<pre><code>&quot;meeting_date&quot;: &quot;2026-10-14&quot;</code></pre>\n<p>; a job application returns its</p>\n<pre><code>role</code></pre>\n<p>. Each follow-up is a typed field of its own: a number, a string, an enum.</p>\n<h2 id=\"why-not-just-ask-everything\">Why not just ask everything?</h2>\n<p>Typed outputs always return a value in the field&#39;s type, even when the question makes no sense. Asked of the same invoice without</p>\n<pre><code>when</code></pre>\n<p>, the follow-ups for a meeting date and a job role came back as the string</p>\n<pre><code>&quot;null&quot;</code></pre>\n<p>and</p>\n<pre><code>&quot;engineering&quot;</code></pre>\n<p>: well-typed, and meaningless. With</p>\n<pre><code>when</code></pre>\n<p>, those fields are skipped instead: they have no key in the result, and</p>\n<pre><code>response.skipped</code></pre>\n<p>lists them.</p>\n<h2 id=\"what-a-condition-can-test\">What a condition can test</h2>\n<pre><code>when</code></pre>\n<p>maps earlier fields to a test of their answers:</p>\n<ul><li><p>No</p><pre><code>depends_on</code></pre>\n<p>needed. The fields a condition names become dependencies, so the field also sees their answers.</p></li><li>Skips carry on. A field that depends on a skipped field is skipped too: its input does not exist.</li><li>Mistakes fail early. A misspelt option, a comparison on a text field or an unknown field is an error before anything runs.</li></ul>\n<h2 id=\"why-one-call-not-your-own-code\">Why one call, not your own code?</h2>\n<p>You could do this yourself: call once to classify, read the answer, then call again with the right follow-up. Doing it in one call is better in four ways.</p>\n<ul><li>The email is read once. Every step continues from the same cached prefix, so the email is processed once, not once per call.</li><li>It is billed once. The TypeLLM API bills what you send in a call, counting the context once. Two calls send, and pay for, the email twice.</li><li><p>No glue code. No parsing the first answer, no</p><pre><code>if</code></pre>\n<p>, no second request to build. The branch lives in the schema, and the answers come back together, with</p>\n<pre><code>skipped</code></pre>\n<p>saying what did not apply.</p></li><li>No round trip in the middle. The condition is checked between steps on the server, so your code never waits on a first answer just to send a second request.</li></ul>\n<h2 id=\"try-it\">Try it</h2>\n<pre><code>when</code></pre>\n<p>is in TypeLLM 0.5.1 and the TypeLLM API. Run the email example in the playground or read the conditional fields docs.</p>","headings":[{"level":1,"text":"Generate only when it applies","id":"generate-only-when-it-applies"},{"level":2,"text":"Sort an email, then ask what that kind needs","id":"sort-an-email-then-ask-what-that-kind-needs"},{"level":2,"text":"Why not just ask everything?","id":"why-not-just-ask-everything"},{"level":2,"text":"What a condition can test","id":"what-a-condition-can-test"},{"level":2,"text":"Why one call, not your own code?","id":"why-one-call-not-your-own-code"},{"level":2,"text":"Try it","id":"try-it"}]}}